Adding in D3D11 GPU skeleton.

This commit is contained in:
Ben Vanik
2013-10-09 23:18:22 -07:00
parent 8558176ee0
commit 611d3bbbeb
10 changed files with 198 additions and 26 deletions

View File

@@ -0,0 +1,88 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#include <xenia/gpu/d3d11/d3d11_graphics_driver.h>
#include <xenia/gpu/gpu-private.h>
#include <xenia/gpu/xenos/ucode_disassembler.h>
using namespace xe;
using namespace xe::gpu;
using namespace xe::gpu::d3d11;
using namespace xe::gpu::xenos;
D3D11GraphicsDriver::D3D11GraphicsDriver(xe_memory_ref memory) :
GraphicsDriver(memory) {
}
D3D11GraphicsDriver::~D3D11GraphicsDriver() {
}
void D3D11GraphicsDriver::Initialize() {
}
void D3D11GraphicsDriver::InvalidateState(
uint32_t mask) {
if (mask == XE_GPU_INVALIDATE_MASK_ALL) {
XELOGGPU("D3D11: (invalidate all)");
}
if (mask & XE_GPU_INVALIDATE_MASK_VERTEX_SHADER) {
XELOGGPU("D3D11: invalidate vertex shader");
}
if (mask & XE_GPU_INVALIDATE_MASK_PIXEL_SHADER) {
XELOGGPU("D3D11: invalidate pixel shader");
}
}
void D3D11GraphicsDriver::SetShader(
XE_GPU_SHADER_TYPE type,
uint32_t address,
uint32_t start,
uint32_t length) {
// Swap shader words.
uint32_t dword_count = length / 4;
XEASSERT(dword_count <= 512);
if (dword_count > 512) {
XELOGGPU("D3D11: ignoring shader %d at %0.8X (%db): too long",
type, address, length);
return;
}
uint8_t* p = xe_memory_addr(memory_, address);
uint32_t dwords[512] = {0};
for (uint32_t n = 0; n < dword_count; n++) {
dwords[n] = XEGETUINT32BE(p + n * 4);
}
// Disassemble.
const char* source = DisassembleShader(type, dwords, dword_count);
if (!source) {
source = "<failed to disassemble>";
}
XELOGGPU("D3D11: set shader %d at %0.8X (%db):\n%s",
type, address, length, source);
if (source) {
xe_free((void*)source);
}
}
void D3D11GraphicsDriver::DrawIndexed(
XE_GPU_PRIMITIVE_TYPE prim_type,
uint32_t index_count) {
XELOGGPU("D3D11: draw indexed %d (%d indicies)",
prim_type, index_count);
// TODO(benvanik):
// program control
// context misc
// interpolator control
// shader constants / bools / integers
// fetch constants
}

View File

@@ -0,0 +1,52 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef XENIA_GPU_D3D11_D3D11_GRAPHICS_DRIVER_H_
#define XENIA_GPU_D3D11_D3D11_GRAPHICS_DRIVER_H_
#include <xenia/core.h>
#include <xenia/gpu/graphics_driver.h>
#include <xenia/gpu/d3d11/d3d11-private.h>
#include <xenia/gpu/xenos/xenos.h>
namespace xe {
namespace gpu {
namespace d3d11 {
class D3D11GraphicsDriver : public GraphicsDriver {
public:
D3D11GraphicsDriver(xe_memory_ref memory);
virtual ~D3D11GraphicsDriver();
virtual void Initialize();
virtual void InvalidateState(
uint32_t mask);
virtual void SetShader(
xenos::XE_GPU_SHADER_TYPE type,
uint32_t address,
uint32_t start,
uint32_t length);
virtual void DrawIndexed(
xenos::XE_GPU_PRIMITIVE_TYPE prim_type,
uint32_t index_count);
protected:
};
} // namespace d3d11
} // namespace gpu
} // namespace xe
#endif // XENIA_GPU_D3D11_D3D11_GRAPHICS_DRIVER_H_

View File

@@ -10,6 +10,7 @@
#include <xenia/gpu/d3d11/d3d11_graphics_system.h>
#include <xenia/gpu/gpu-private.h>
#include <xenia/gpu/d3d11/d3d11_graphics_driver.h>
using namespace xe;
@@ -24,11 +25,7 @@ D3D11GraphicsSystem::D3D11GraphicsSystem(const CreationParams* params) :
D3D11GraphicsSystem::~D3D11GraphicsSystem() {
}
uint64_t D3D11GraphicsSystem::ReadRegister(uint32_t r) {
XELOGGPU("ReadRegister(%.4X)", r);
return 0;
}
void D3D11GraphicsSystem::WriteRegister(uint32_t r, uint64_t value) {
XELOGGPU("WriteRegister(%.4X, %.8X)", r, value);
void D3D11GraphicsSystem::Initialize() {
XEASSERTNULL(driver_);
driver_ = new D3D11GraphicsDriver(memory_);
}

View File

@@ -29,8 +29,7 @@ public:
D3D11GraphicsSystem(const CreationParams* params);
virtual ~D3D11GraphicsSystem();
virtual uint64_t ReadRegister(uint32_t r);
virtual void WriteRegister(uint32_t r, uint64_t value);
virtual void Initialize();
};

View File

@@ -4,6 +4,8 @@
'd3d11-private.h',
'd3d11.cc',
'd3d11.h',
'd3d11_graphics_driver.cc',
'd3d11_graphics_driver.h',
'd3d11_graphics_system.cc',
'd3d11_graphics_system.h',
],