[D3D12] Load D3D dynamically
This commit is contained in:
@@ -367,7 +367,7 @@ ID3D12RootSignature* D3D12CommandProcessor::GetRootSignature(
|
||||
}
|
||||
|
||||
ID3D12RootSignature* root_signature = ui::d3d12::util::CreateRootSignature(
|
||||
GetD3D12Context()->GetD3D12Provider()->GetDevice(), desc);
|
||||
GetD3D12Context()->GetD3D12Provider(), desc);
|
||||
if (root_signature == nullptr) {
|
||||
XELOGE(
|
||||
"Failed to create a root signature with %u pixel textures, %u pixel "
|
||||
|
||||
@@ -41,8 +41,8 @@ X_STATUS D3D12GraphicsSystem::Setup(cpu::Processor* processor,
|
||||
kernel::KernelState* kernel_state,
|
||||
ui::Window* target_window) {
|
||||
provider_ = xe::ui::d3d12::D3D12Provider::Create(target_window);
|
||||
auto device =
|
||||
static_cast<xe::ui::d3d12::D3D12Provider*>(provider())->GetDevice();
|
||||
auto d3d12_provider = static_cast<xe::ui::d3d12::D3D12Provider*>(provider());
|
||||
auto device = d3d12_provider->GetDevice();
|
||||
|
||||
auto result = GraphicsSystem::Setup(processor, kernel_state, target_window);
|
||||
if (result != X_STATUS_SUCCESS) {
|
||||
@@ -93,7 +93,7 @@ X_STATUS D3D12GraphicsSystem::Setup(cpu::Processor* processor,
|
||||
stretch_root_desc.Flags =
|
||||
D3D12_ROOT_SIGNATURE_FLAG_DENY_VERTEX_SHADER_ROOT_ACCESS;
|
||||
stretch_root_signature_ =
|
||||
ui::d3d12::util::CreateRootSignature(device, stretch_root_desc);
|
||||
ui::d3d12::util::CreateRootSignature(d3d12_provider, stretch_root_desc);
|
||||
if (stretch_root_signature_ == nullptr) {
|
||||
XELOGE("Failed to create the front buffer stretch root signature");
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
@@ -120,7 +120,7 @@ X_STATUS D3D12GraphicsSystem::Setup(cpu::Processor* processor,
|
||||
stretch_root_desc.NumParameters = 3;
|
||||
stretch_root_desc.pParameters = stretch_root_parameters;
|
||||
stretch_gamma_root_signature_ =
|
||||
ui::d3d12::util::CreateRootSignature(device, stretch_root_desc);
|
||||
ui::d3d12::util::CreateRootSignature(d3d12_provider, stretch_root_desc);
|
||||
if (stretch_gamma_root_signature_ == nullptr) {
|
||||
XELOGE(
|
||||
"Failed to create the gamma-correcting front buffer stretch root "
|
||||
|
||||
@@ -60,16 +60,16 @@ void D3D12Shader::SetTexturesAndSamplers(
|
||||
}
|
||||
}
|
||||
|
||||
bool D3D12Shader::DisassembleDXBC() {
|
||||
bool D3D12Shader::DisassembleDXBC(const ui::d3d12::D3D12Provider* provider) {
|
||||
if (!host_disassembly_.empty()) {
|
||||
return true;
|
||||
}
|
||||
ID3DBlob* blob;
|
||||
if (FAILED(D3DDisassemble(translated_binary().data(),
|
||||
translated_binary().size(),
|
||||
D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING |
|
||||
D3D_DISASM_ENABLE_INSTRUCTION_OFFSET,
|
||||
nullptr, &blob))) {
|
||||
if (FAILED(provider->Disassemble(translated_binary().data(),
|
||||
translated_binary().size(),
|
||||
D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING |
|
||||
D3D_DISASM_ENABLE_INSTRUCTION_OFFSET,
|
||||
nullptr, &blob))) {
|
||||
return false;
|
||||
}
|
||||
host_disassembly_ = reinterpret_cast<const char*>(blob->GetBufferPointer());
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "xenia/gpu/dxbc_shader_translator.h"
|
||||
#include "xenia/gpu/shader.h"
|
||||
#include "xenia/ui/d3d12/d3d12_provider.h"
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
@@ -30,7 +31,7 @@ class D3D12Shader : public Shader {
|
||||
const DxbcShaderTranslator::SamplerBinding* sampler_bindings,
|
||||
uint32_t sampler_binding_count);
|
||||
|
||||
bool DisassembleDXBC();
|
||||
bool DisassembleDXBC(const ui::d3d12::D3D12Provider* provider);
|
||||
|
||||
static constexpr uint32_t kMaxTextureSRVIndexBits =
|
||||
DxbcShaderTranslator::kMaxTextureSRVIndexBits;
|
||||
|
||||
@@ -224,7 +224,8 @@ bool PipelineCache::TranslateShader(D3D12Shader* shader,
|
||||
|
||||
// Disassemble the shader for dumping.
|
||||
if (FLAGS_d3d12_dxbc_disasm) {
|
||||
if (!shader->DisassembleDXBC()) {
|
||||
auto provider = command_processor_->GetD3D12Context()->GetD3D12Provider();
|
||||
if (!shader->DisassembleDXBC(provider)) {
|
||||
XELOGE("Failed to disassemble DXBC shader %.16" PRIX64,
|
||||
shader->ucode_data_hash());
|
||||
}
|
||||
|
||||
@@ -76,8 +76,8 @@ RenderTargetCache::RenderTargetCache(D3D12CommandProcessor* command_processor,
|
||||
RenderTargetCache::~RenderTargetCache() { Shutdown(); }
|
||||
|
||||
bool RenderTargetCache::Initialize() {
|
||||
auto device =
|
||||
command_processor_->GetD3D12Context()->GetD3D12Provider()->GetDevice();
|
||||
auto provider = command_processor_->GetD3D12Context()->GetD3D12Provider();
|
||||
auto device = provider->GetDevice();
|
||||
|
||||
// Create the buffer for reinterpreting EDRAM contents.
|
||||
D3D12_RESOURCE_DESC edram_buffer_desc;
|
||||
@@ -132,7 +132,7 @@ bool RenderTargetCache::Initialize() {
|
||||
load_store_root_desc.Flags = D3D12_ROOT_SIGNATURE_FLAG_NONE;
|
||||
|
||||
edram_load_store_root_signature_ =
|
||||
ui::d3d12::util::CreateRootSignature(device, load_store_root_desc);
|
||||
ui::d3d12::util::CreateRootSignature(provider, load_store_root_desc);
|
||||
if (edram_load_store_root_signature_ == nullptr) {
|
||||
XELOGE("Failed to create the EDRAM load/store root signature");
|
||||
Shutdown();
|
||||
@@ -142,7 +142,7 @@ bool RenderTargetCache::Initialize() {
|
||||
load_store_root_parameters[1].DescriptorTable.NumDescriptorRanges = 1;
|
||||
++load_store_root_parameters[1].DescriptorTable.pDescriptorRanges;
|
||||
edram_clear_root_signature_ =
|
||||
ui::d3d12::util::CreateRootSignature(device, load_store_root_desc);
|
||||
ui::d3d12::util::CreateRootSignature(provider, load_store_root_desc);
|
||||
if (edram_clear_root_signature_ == nullptr) {
|
||||
XELOGE("Failed to create the EDRAM buffer clear root signature");
|
||||
Shutdown();
|
||||
@@ -265,7 +265,7 @@ bool RenderTargetCache::Initialize() {
|
||||
resolve_root_desc.Flags =
|
||||
D3D12_ROOT_SIGNATURE_FLAG_DENY_VERTEX_SHADER_ROOT_ACCESS;
|
||||
resolve_root_signature_ =
|
||||
ui::d3d12::util::CreateRootSignature(device, resolve_root_desc);
|
||||
ui::d3d12::util::CreateRootSignature(provider, resolve_root_desc);
|
||||
if (resolve_root_signature_ == nullptr) {
|
||||
XELOGE("Failed to create the converting resolve root signature");
|
||||
Shutdown();
|
||||
|
||||
@@ -369,8 +369,8 @@ TextureCache::TextureCache(D3D12CommandProcessor* command_processor,
|
||||
TextureCache::~TextureCache() { Shutdown(); }
|
||||
|
||||
bool TextureCache::Initialize() {
|
||||
auto device =
|
||||
command_processor_->GetD3D12Context()->GetD3D12Provider()->GetDevice();
|
||||
auto provider = command_processor_->GetD3D12Context()->GetD3D12Provider();
|
||||
auto device = provider->GetDevice();
|
||||
|
||||
// Create the loading root signature.
|
||||
D3D12_ROOT_PARAMETER root_parameters[2];
|
||||
@@ -402,7 +402,7 @@ bool TextureCache::Initialize() {
|
||||
root_signature_desc.pStaticSamplers = nullptr;
|
||||
root_signature_desc.Flags = D3D12_ROOT_SIGNATURE_FLAG_NONE;
|
||||
load_root_signature_ =
|
||||
ui::d3d12::util::CreateRootSignature(device, root_signature_desc);
|
||||
ui::d3d12::util::CreateRootSignature(provider, root_signature_desc);
|
||||
if (load_root_signature_ == nullptr) {
|
||||
XELOGE("Failed to create the texture loading root signature");
|
||||
Shutdown();
|
||||
@@ -416,7 +416,7 @@ bool TextureCache::Initialize() {
|
||||
root_parameters[0].Constants.Num32BitValues =
|
||||
sizeof(ResolveTileConstants) / sizeof(uint32_t);
|
||||
resolve_tile_root_signature_ =
|
||||
ui::d3d12::util::CreateRootSignature(device, root_signature_desc);
|
||||
ui::d3d12::util::CreateRootSignature(provider, root_signature_desc);
|
||||
if (resolve_tile_root_signature_ == nullptr) {
|
||||
XELOGE("Failed to create the texture tiling root signature");
|
||||
Shutdown();
|
||||
|
||||
@@ -124,13 +124,21 @@ int shader_compiler_main(const std::vector<std::wstring>& args) {
|
||||
#if XE_PLATFORM_WIN32
|
||||
ID3DBlob* dxbc_disasm_blob = nullptr;
|
||||
if (FLAGS_shader_output_type == "dxbc") {
|
||||
// Diassemble DXBC.
|
||||
if (SUCCEEDED(D3DDisassemble(source_data, source_data_size,
|
||||
D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING |
|
||||
D3D_DISASM_ENABLE_INSTRUCTION_OFFSET,
|
||||
nullptr, &dxbc_disasm_blob))) {
|
||||
source_data = dxbc_disasm_blob->GetBufferPointer();
|
||||
source_data_size = dxbc_disasm_blob->GetBufferSize();
|
||||
HMODULE d3d_compiler = LoadLibrary(L"D3DCompiler_47.dll");
|
||||
if (d3d_compiler != nullptr) {
|
||||
pD3DDisassemble d3d_disassemble =
|
||||
pD3DDisassemble(GetProcAddress(d3d_compiler, "D3DDisassemble"));
|
||||
if (d3d_disassemble != nullptr) {
|
||||
// Disassemble DXBC.
|
||||
if (SUCCEEDED(d3d_disassemble(source_data, source_data_size,
|
||||
D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING |
|
||||
D3D_DISASM_ENABLE_INSTRUCTION_OFFSET,
|
||||
nullptr, &dxbc_disasm_blob))) {
|
||||
source_data = dxbc_disasm_blob->GetBufferPointer();
|
||||
source_data_size = dxbc_disasm_blob->GetBufferSize();
|
||||
}
|
||||
}
|
||||
FreeLibrary(d3d_compiler);
|
||||
}
|
||||
}
|
||||
#endif // XE_PLATFORM_WIN32
|
||||
|
||||
Reference in New Issue
Block a user