[D3D12] Refactor root signature creation
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/ui/d3d12/d3d12_util.h"
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
@@ -172,33 +173,13 @@ bool D3D12ImmediateDrawer::Initialize() {
|
||||
root_signature_desc.pStaticSamplers = nullptr;
|
||||
root_signature_desc.Flags =
|
||||
D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT;
|
||||
ID3DBlob* root_signature_blob;
|
||||
ID3DBlob* root_signature_error_blob = nullptr;
|
||||
if (FAILED(D3D12SerializeRootSignature(
|
||||
&root_signature_desc, D3D_ROOT_SIGNATURE_VERSION_1,
|
||||
&root_signature_blob, &root_signature_error_blob))) {
|
||||
XELOGE("Failed to serialize immediate drawer root signature");
|
||||
if (root_signature_error_blob != nullptr) {
|
||||
XELOGE("%s", reinterpret_cast<const char*>(
|
||||
root_signature_error_blob->GetBufferPointer()));
|
||||
root_signature_error_blob->Release();
|
||||
}
|
||||
root_signature_ =
|
||||
ui::d3d12::util::CreateRootSignature(device, root_signature_desc);
|
||||
if (root_signature_ == nullptr) {
|
||||
XELOGE("Failed to create the immediate drawer root signature");
|
||||
Shutdown();
|
||||
return false;
|
||||
}
|
||||
if (root_signature_error_blob != nullptr) {
|
||||
root_signature_error_blob->Release();
|
||||
}
|
||||
if (FAILED(device->CreateRootSignature(
|
||||
0, root_signature_blob->GetBufferPointer(),
|
||||
root_signature_blob->GetBufferSize(),
|
||||
IID_PPV_ARGS(&root_signature_)))) {
|
||||
XELOGE("Failed to create immediate drawer root signature");
|
||||
root_signature_blob->Release();
|
||||
Shutdown();
|
||||
return false;
|
||||
}
|
||||
root_signature_blob->Release();
|
||||
|
||||
// Create the pipelines.
|
||||
D3D12_GRAPHICS_PIPELINE_STATE_DESC pipeline_desc = {};
|
||||
|
||||
47
src/xenia/ui/d3d12/d3d12_util.cc
Normal file
47
src/xenia/ui/d3d12/d3d12_util.cc
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2018 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "xenia/ui/d3d12/d3d12_util.h"
|
||||
|
||||
#include "xenia/base/logging.h"
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
namespace d3d12 {
|
||||
namespace util {
|
||||
|
||||
ID3D12RootSignature* CreateRootSignature(
|
||||
ID3D12Device* device, const D3D12_ROOT_SIGNATURE_DESC& desc) {
|
||||
ID3DBlob* blob;
|
||||
ID3DBlob* error_blob = nullptr;
|
||||
if (FAILED(D3D12SerializeRootSignature(&desc, D3D_ROOT_SIGNATURE_VERSION_1,
|
||||
&blob, &error_blob))) {
|
||||
XELOGE("Failed to serialize a root signature");
|
||||
if (error_blob != nullptr) {
|
||||
XELOGE("%s",
|
||||
reinterpret_cast<const char*>(error_blob->GetBufferPointer()));
|
||||
error_blob->Release();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
if (error_blob != nullptr) {
|
||||
error_blob->Release();
|
||||
}
|
||||
ID3D12RootSignature* root_signature = nullptr;
|
||||
device->CreateRootSignature(0, blob->GetBufferPointer(),
|
||||
blob->GetBufferSize(),
|
||||
IID_PPV_ARGS(&root_signature));
|
||||
blob->Release();
|
||||
return root_signature;
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace d3d12
|
||||
} // namespace ui
|
||||
} // namespace xe
|
||||
37
src/xenia/ui/d3d12/d3d12_util.h
Normal file
37
src/xenia/ui/d3d12/d3d12_util.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2018 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_UI_D3D12_D3D12_UTIL_H_
|
||||
#define XENIA_UI_D3D12_D3D12_UTIL_H_
|
||||
|
||||
#include "xenia/ui/d3d12/d3d12_provider.h"
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
namespace d3d12 {
|
||||
namespace util {
|
||||
|
||||
inline bool ReleaseAndNull(IUnknown*& object) {
|
||||
if (object != nullptr) {
|
||||
object->Release();
|
||||
object = nullptr;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
ID3D12RootSignature* CreateRootSignature(ID3D12Device* device,
|
||||
const D3D12_ROOT_SIGNATURE_DESC& desc);
|
||||
|
||||
} // namespace util
|
||||
} // namespace d3d12
|
||||
} // namespace ui
|
||||
} // namespace xe
|
||||
|
||||
#endif // XENIA_UI_D3D12_D3D12_UTIL_H_
|
||||
Reference in New Issue
Block a user