Adding in D3D11 GPU skeleton.
This commit is contained in:
parent
8558176ee0
commit
611d3bbbeb
|
@ -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
|
||||
}
|
|
@ -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_
|
|
@ -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_);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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',
|
||||
],
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <gflags/gflags.h>
|
||||
|
||||
|
||||
// DECLARE_ flags here
|
||||
DECLARE_string(gpu);
|
||||
|
||||
|
||||
#endif // XENIA_GPU_PRIVATE_H_
|
||||
|
|
|
@ -10,27 +10,49 @@
|
|||
#include <xenia/gpu/gpu.h>
|
||||
#include <xenia/gpu/gpu-private.h>
|
||||
|
||||
#if XE_PLATFORM(WIN32)
|
||||
//#include <xenia/gpu/d3d11/d3d11.h>
|
||||
#endif // WIN32
|
||||
#include <xenia/gpu/nop/nop.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::gpu;
|
||||
|
||||
|
||||
// DEFINE_ flags here.
|
||||
DEFINE_string(gpu, "any",
|
||||
"Graphics system. Use: [any, nop, d3d11]");
|
||||
|
||||
|
||||
GraphicsSystem* xe::gpu::Create(const CreationParams* params) {
|
||||
// TODO(benvanik): use flags to determine system, check support, etc.
|
||||
return xe::gpu::nop::Create(params);
|
||||
// #if XE_PLATFORM(WIN32)
|
||||
// return xe::gpu::d3d11::Create(params);
|
||||
// #endif // WIN32
|
||||
}
|
||||
|
||||
#include <xenia/gpu/nop/nop.h>
|
||||
GraphicsSystem* xe::gpu::CreateNop(const CreationParams* params) {
|
||||
return xe::gpu::nop::Create(params);
|
||||
}
|
||||
|
||||
|
||||
#if XE_PLATFORM(WIN32)
|
||||
#include <xenia/gpu/d3d11/d3d11.h>
|
||||
GraphicsSystem* xe::gpu::CreateD3D11(const CreationParams* params) {
|
||||
return xe::gpu::d3d11::Create(params);
|
||||
}
|
||||
#endif // WIN32
|
||||
|
||||
|
||||
GraphicsSystem* xe::gpu::Create(const CreationParams* params) {
|
||||
if (FLAGS_gpu.compare("nop") == 0) {
|
||||
return CreateNop(params);
|
||||
#if XE_PLATFORM(WIN32)
|
||||
} else if (FLAGS_gpu.compare("d3d11") == 0) {
|
||||
return CreateD3D11(params);
|
||||
#endif // WIN32
|
||||
} else {
|
||||
// Create best available.
|
||||
GraphicsSystem* best = NULL;
|
||||
|
||||
#if XE_PLATFORM(WIN32)
|
||||
best = CreateD3D11(params);
|
||||
if (best) {
|
||||
return best;
|
||||
}
|
||||
#endif // WIN32
|
||||
|
||||
// Fallback to nop.
|
||||
return CreateNop(params);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,13 @@ namespace gpu {
|
|||
|
||||
|
||||
GraphicsSystem* Create(const CreationParams* params);
|
||||
|
||||
GraphicsSystem* CreateNop(const CreationParams* params);
|
||||
|
||||
#if XE_PLATFORM(WIN32)
|
||||
GraphicsSystem* CreateD3D11(const CreationParams* params);
|
||||
#endif // WIN32
|
||||
|
||||
|
||||
} // namespace gpu
|
||||
} // namespace xe
|
||||
|
|
|
@ -76,6 +76,13 @@ void NopGraphicsDriver::SetShader(
|
|||
void NopGraphicsDriver::DrawIndexed(
|
||||
XE_GPU_PRIMITIVE_TYPE prim_type,
|
||||
uint32_t index_count) {
|
||||
XELOGGPU("NOP: draw indexed %d (%d indicies)",
|
||||
prim_type, index_count);
|
||||
XELOGGPU("NOP: draw indexed %d (%d indicies)",
|
||||
prim_type, index_count);
|
||||
|
||||
// TODO(benvanik):
|
||||
// program control
|
||||
// context misc
|
||||
// interpolator control
|
||||
// shader constants / bools / integers
|
||||
// fetch constants
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
'conditions': [
|
||||
['OS == "win"', {
|
||||
'includes': [
|
||||
#'d3d11/sources.gypi',
|
||||
'd3d11/sources.gypi',
|
||||
],
|
||||
}],
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue