[D3D12] Non-zeroed heaps on 2004
This commit is contained in:
parent
b3f84f4a9c
commit
38e0cc4941
|
@ -12,7 +12,7 @@ drivers.
|
||||||
* [Visual Studio 2019 or Visual Studio 2017](https://www.visualstudio.com/downloads/)
|
* [Visual Studio 2019 or Visual Studio 2017](https://www.visualstudio.com/downloads/)
|
||||||
* [Python 3.6+](https://www.python.org/downloads/)
|
* [Python 3.6+](https://www.python.org/downloads/)
|
||||||
* Ensure Python is in PATH.
|
* Ensure Python is in PATH.
|
||||||
* Windows 10 SDK
|
* Windows 10 SDK version 10.0.19041.0 (for Visual Studio 2019, this or any newer version)
|
||||||
|
|
||||||
```
|
```
|
||||||
git clone https://github.com/xenia-project/xenia.git
|
git clone https://github.com/xenia-project/xenia.git
|
||||||
|
|
|
@ -202,10 +202,10 @@ solution("xenia")
|
||||||
platforms({"Linux"})
|
platforms({"Linux"})
|
||||||
elseif os.istarget("windows") then
|
elseif os.istarget("windows") then
|
||||||
platforms({"Windows"})
|
platforms({"Windows"})
|
||||||
-- Minimum version to support ID3D12GraphicsCommandList1 (for
|
-- 10.0.15063.0: ID3D12GraphicsCommandList1::SetSamplePositions.
|
||||||
-- SetSamplePositions).
|
-- 10.0.19041.0: D3D12_HEAP_FLAG_CREATE_NOT_ZEROED.
|
||||||
filter("action:vs2017")
|
filter("action:vs2017")
|
||||||
systemversion("10.0.15063.0")
|
systemversion("10.0.19041.0")
|
||||||
filter("action:vs2019")
|
filter("action:vs2019")
|
||||||
systemversion("10.0")
|
systemversion("10.0")
|
||||||
filter({})
|
filter({})
|
||||||
|
|
|
@ -646,14 +646,16 @@ ID3D12Resource* D3D12CommandProcessor::RequestScratchGPUBuffer(
|
||||||
|
|
||||||
size = xe::align(size, kScratchBufferSizeIncrement);
|
size = xe::align(size, kScratchBufferSizeIncrement);
|
||||||
|
|
||||||
auto device = GetD3D12Context().GetD3D12Provider().GetDevice();
|
auto& provider = GetD3D12Context().GetD3D12Provider();
|
||||||
|
auto device = provider.GetDevice();
|
||||||
D3D12_RESOURCE_DESC buffer_desc;
|
D3D12_RESOURCE_DESC buffer_desc;
|
||||||
ui::d3d12::util::FillBufferResourceDesc(
|
ui::d3d12::util::FillBufferResourceDesc(
|
||||||
buffer_desc, size, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS);
|
buffer_desc, size, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS);
|
||||||
ID3D12Resource* buffer;
|
ID3D12Resource* buffer;
|
||||||
if (FAILED(device->CreateCommittedResource(
|
if (FAILED(device->CreateCommittedResource(
|
||||||
&ui::d3d12::util::kHeapPropertiesDefault, D3D12_HEAP_FLAG_NONE,
|
&ui::d3d12::util::kHeapPropertiesDefault,
|
||||||
&buffer_desc, state, nullptr, IID_PPV_ARGS(&buffer)))) {
|
provider.GetHeapFlagCreateNotZeroed(), &buffer_desc, state, nullptr,
|
||||||
|
IID_PPV_ARGS(&buffer)))) {
|
||||||
XELOGE("Failed to create a {} MB scratch GPU buffer", size >> 20);
|
XELOGE("Failed to create a {} MB scratch GPU buffer", size >> 20);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -889,7 +891,7 @@ bool D3D12CommandProcessor::SetupContext() {
|
||||||
|
|
||||||
// Initialize resource binding.
|
// Initialize resource binding.
|
||||||
constant_buffer_pool_ =
|
constant_buffer_pool_ =
|
||||||
std::make_unique<ui::d3d12::UploadBufferPool>(device, 1024 * 1024);
|
std::make_unique<ui::d3d12::UploadBufferPool>(provider, 1024 * 1024);
|
||||||
if (bindless_resources_used_) {
|
if (bindless_resources_used_) {
|
||||||
D3D12_DESCRIPTOR_HEAP_DESC view_bindless_heap_desc;
|
D3D12_DESCRIPTOR_HEAP_DESC view_bindless_heap_desc;
|
||||||
view_bindless_heap_desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
|
view_bindless_heap_desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
|
||||||
|
@ -1181,6 +1183,9 @@ bool D3D12CommandProcessor::SetupContext() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
D3D12_HEAP_FLAGS heap_flag_create_not_zeroed =
|
||||||
|
provider.GetHeapFlagCreateNotZeroed();
|
||||||
|
|
||||||
// Create gamma ramp resources. The PWL gamma ramp is 16-bit, but 6 bits are
|
// Create gamma ramp resources. The PWL gamma ramp is 16-bit, but 6 bits are
|
||||||
// hardwired to zero, so DXGI_FORMAT_R10G10B10A2_UNORM can be used for it too.
|
// hardwired to zero, so DXGI_FORMAT_R10G10B10A2_UNORM can be used for it too.
|
||||||
// https://www.x.org/docs/AMD/old/42590_m76_rrg_1.01o.pdf
|
// https://www.x.org/docs/AMD/old/42590_m76_rrg_1.01o.pdf
|
||||||
|
@ -1202,7 +1207,7 @@ bool D3D12CommandProcessor::SetupContext() {
|
||||||
// The first action will be uploading.
|
// The first action will be uploading.
|
||||||
gamma_ramp_texture_state_ = D3D12_RESOURCE_STATE_COPY_DEST;
|
gamma_ramp_texture_state_ = D3D12_RESOURCE_STATE_COPY_DEST;
|
||||||
if (FAILED(device->CreateCommittedResource(
|
if (FAILED(device->CreateCommittedResource(
|
||||||
&ui::d3d12::util::kHeapPropertiesDefault, D3D12_HEAP_FLAG_NONE,
|
&ui::d3d12::util::kHeapPropertiesDefault, heap_flag_create_not_zeroed,
|
||||||
&gamma_ramp_desc, gamma_ramp_texture_state_, nullptr,
|
&gamma_ramp_desc, gamma_ramp_texture_state_, nullptr,
|
||||||
IID_PPV_ARGS(&gamma_ramp_texture_)))) {
|
IID_PPV_ARGS(&gamma_ramp_texture_)))) {
|
||||||
XELOGE("Failed to create the gamma ramp texture");
|
XELOGE("Failed to create the gamma ramp texture");
|
||||||
|
@ -1218,7 +1223,7 @@ bool D3D12CommandProcessor::SetupContext() {
|
||||||
ui::d3d12::util::FillBufferResourceDesc(
|
ui::d3d12::util::FillBufferResourceDesc(
|
||||||
gamma_ramp_desc, gamma_ramp_upload_size, D3D12_RESOURCE_FLAG_NONE);
|
gamma_ramp_desc, gamma_ramp_upload_size, D3D12_RESOURCE_FLAG_NONE);
|
||||||
if (FAILED(device->CreateCommittedResource(
|
if (FAILED(device->CreateCommittedResource(
|
||||||
&ui::d3d12::util::kHeapPropertiesUpload, D3D12_HEAP_FLAG_NONE,
|
&ui::d3d12::util::kHeapPropertiesUpload, heap_flag_create_not_zeroed,
|
||||||
&gamma_ramp_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
|
&gamma_ramp_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
|
||||||
IID_PPV_ARGS(&gamma_ramp_upload_)))) {
|
IID_PPV_ARGS(&gamma_ramp_upload_)))) {
|
||||||
XELOGE("Failed to create the gamma ramp upload buffer");
|
XELOGE("Failed to create the gamma ramp upload buffer");
|
||||||
|
@ -1246,7 +1251,7 @@ bool D3D12CommandProcessor::SetupContext() {
|
||||||
swap_texture_desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
|
swap_texture_desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
|
||||||
// Can be sampled at any time, switch to render target when needed, then back.
|
// Can be sampled at any time, switch to render target when needed, then back.
|
||||||
if (FAILED(device->CreateCommittedResource(
|
if (FAILED(device->CreateCommittedResource(
|
||||||
&ui::d3d12::util::kHeapPropertiesDefault, D3D12_HEAP_FLAG_NONE,
|
&ui::d3d12::util::kHeapPropertiesDefault, heap_flag_create_not_zeroed,
|
||||||
&swap_texture_desc, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
|
&swap_texture_desc, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
|
||||||
nullptr, IID_PPV_ARGS(&swap_texture_)))) {
|
nullptr, IID_PPV_ARGS(&swap_texture_)))) {
|
||||||
XELOGE("Failed to create the command processor front buffer");
|
XELOGE("Failed to create the command processor front buffer");
|
||||||
|
@ -4286,15 +4291,16 @@ ID3D12Resource* D3D12CommandProcessor::RequestReadbackBuffer(uint32_t size) {
|
||||||
}
|
}
|
||||||
size = xe::align(size, kReadbackBufferSizeIncrement);
|
size = xe::align(size, kReadbackBufferSizeIncrement);
|
||||||
if (size > readback_buffer_size_) {
|
if (size > readback_buffer_size_) {
|
||||||
auto device = GetD3D12Context().GetD3D12Provider().GetDevice();
|
auto& provider = GetD3D12Context().GetD3D12Provider();
|
||||||
|
auto device = provider.GetDevice();
|
||||||
D3D12_RESOURCE_DESC buffer_desc;
|
D3D12_RESOURCE_DESC buffer_desc;
|
||||||
ui::d3d12::util::FillBufferResourceDesc(buffer_desc, size,
|
ui::d3d12::util::FillBufferResourceDesc(buffer_desc, size,
|
||||||
D3D12_RESOURCE_FLAG_NONE);
|
D3D12_RESOURCE_FLAG_NONE);
|
||||||
ID3D12Resource* buffer;
|
ID3D12Resource* buffer;
|
||||||
if (FAILED(device->CreateCommittedResource(
|
if (FAILED(device->CreateCommittedResource(
|
||||||
&ui::d3d12::util::kHeapPropertiesReadback, D3D12_HEAP_FLAG_NONE,
|
&ui::d3d12::util::kHeapPropertiesReadback,
|
||||||
&buffer_desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
|
provider.GetHeapFlagCreateNotZeroed(), &buffer_desc,
|
||||||
IID_PPV_ARGS(&buffer)))) {
|
D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS(&buffer)))) {
|
||||||
XELOGE("Failed to create a {} MB readback buffer", size >> 20);
|
XELOGE("Failed to create a {} MB readback buffer", size >> 20);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,14 +47,16 @@ PrimitiveConverter::PrimitiveConverter(D3D12CommandProcessor& command_processor,
|
||||||
PrimitiveConverter::~PrimitiveConverter() { Shutdown(); }
|
PrimitiveConverter::~PrimitiveConverter() { Shutdown(); }
|
||||||
|
|
||||||
bool PrimitiveConverter::Initialize() {
|
bool PrimitiveConverter::Initialize() {
|
||||||
auto device =
|
auto& provider = command_processor_.GetD3D12Context().GetD3D12Provider();
|
||||||
command_processor_.GetD3D12Context().GetD3D12Provider().GetDevice();
|
auto device = provider.GetDevice();
|
||||||
|
D3D12_HEAP_FLAGS heap_flag_create_not_zeroed =
|
||||||
|
provider.GetHeapFlagCreateNotZeroed();
|
||||||
|
|
||||||
// There can be at most 65535 indices in a Xenos draw call, but they can be up
|
// There can be at most 65535 indices in a Xenos draw call, but they can be up
|
||||||
// to 4 bytes large, and conversion can add more indices (almost triple the
|
// to 4 bytes large, and conversion can add more indices (almost triple the
|
||||||
// count for triangle strips, for instance).
|
// count for triangle strips, for instance).
|
||||||
buffer_pool_ =
|
buffer_pool_ =
|
||||||
std::make_unique<ui::d3d12::UploadBufferPool>(device, 4 * 1024 * 1024);
|
std::make_unique<ui::d3d12::UploadBufferPool>(provider, 4 * 1024 * 1024);
|
||||||
|
|
||||||
// Create the static index buffer for non-indexed drawing.
|
// Create the static index buffer for non-indexed drawing.
|
||||||
D3D12_RESOURCE_DESC static_ib_desc;
|
D3D12_RESOURCE_DESC static_ib_desc;
|
||||||
|
@ -62,7 +64,7 @@ bool PrimitiveConverter::Initialize() {
|
||||||
static_ib_desc, kStaticIBTotalCount * sizeof(uint16_t),
|
static_ib_desc, kStaticIBTotalCount * sizeof(uint16_t),
|
||||||
D3D12_RESOURCE_FLAG_NONE);
|
D3D12_RESOURCE_FLAG_NONE);
|
||||||
if (FAILED(device->CreateCommittedResource(
|
if (FAILED(device->CreateCommittedResource(
|
||||||
&ui::d3d12::util::kHeapPropertiesUpload, D3D12_HEAP_FLAG_NONE,
|
&ui::d3d12::util::kHeapPropertiesUpload, heap_flag_create_not_zeroed,
|
||||||
&static_ib_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
|
&static_ib_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
|
||||||
IID_PPV_ARGS(&static_ib_upload_)))) {
|
IID_PPV_ARGS(&static_ib_upload_)))) {
|
||||||
XELOGE(
|
XELOGE(
|
||||||
|
@ -108,7 +110,7 @@ bool PrimitiveConverter::Initialize() {
|
||||||
// Not uploaded yet.
|
// Not uploaded yet.
|
||||||
static_ib_upload_submission_ = UINT64_MAX;
|
static_ib_upload_submission_ = UINT64_MAX;
|
||||||
if (FAILED(device->CreateCommittedResource(
|
if (FAILED(device->CreateCommittedResource(
|
||||||
&ui::d3d12::util::kHeapPropertiesDefault, D3D12_HEAP_FLAG_NONE,
|
&ui::d3d12::util::kHeapPropertiesDefault, heap_flag_create_not_zeroed,
|
||||||
&static_ib_desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
|
&static_ib_desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
|
||||||
IID_PPV_ARGS(&static_ib_)))) {
|
IID_PPV_ARGS(&static_ib_)))) {
|
||||||
XELOGE("Failed to create the primitive conversion static index buffer");
|
XELOGE("Failed to create the primitive conversion static index buffer");
|
||||||
|
|
|
@ -137,8 +137,6 @@ bool RenderTargetCache::Initialize(const TextureCache& texture_cache) {
|
||||||
uint32_t edram_buffer_size = GetEdramBufferSize();
|
uint32_t edram_buffer_size = GetEdramBufferSize();
|
||||||
|
|
||||||
// Create the buffer for reinterpreting EDRAM contents.
|
// Create the buffer for reinterpreting EDRAM contents.
|
||||||
// No need to clear it in the first frame, memory is zeroed out when allocated
|
|
||||||
// on Windows.
|
|
||||||
D3D12_RESOURCE_DESC edram_buffer_desc;
|
D3D12_RESOURCE_DESC edram_buffer_desc;
|
||||||
ui::d3d12::util::FillBufferResourceDesc(
|
ui::d3d12::util::FillBufferResourceDesc(
|
||||||
edram_buffer_desc, edram_buffer_size,
|
edram_buffer_desc, edram_buffer_size,
|
||||||
|
@ -147,8 +145,15 @@ bool RenderTargetCache::Initialize(const TextureCache& texture_cache) {
|
||||||
edram_buffer_state_ = edram_rov_used_
|
edram_buffer_state_ = edram_rov_used_
|
||||||
? D3D12_RESOURCE_STATE_UNORDERED_ACCESS
|
? D3D12_RESOURCE_STATE_UNORDERED_ACCESS
|
||||||
: D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE;
|
: D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE;
|
||||||
|
// Request zeroed (though no guarantee) when not using ROV so the host 32-bit
|
||||||
|
// depth buffer will be initialized to deterministic values (because it's
|
||||||
|
// involved in comparison with converted 24-bit values - whether the 32-bit
|
||||||
|
// value is up to date is determined by whether it's equal to the 24-bit
|
||||||
|
// value in the main EDRAM buffer when converted to 24-bit).
|
||||||
if (FAILED(device->CreateCommittedResource(
|
if (FAILED(device->CreateCommittedResource(
|
||||||
&ui::d3d12::util::kHeapPropertiesDefault, D3D12_HEAP_FLAG_NONE,
|
&ui::d3d12::util::kHeapPropertiesDefault,
|
||||||
|
edram_rov_used_ ? provider.GetHeapFlagCreateNotZeroed()
|
||||||
|
: D3D12_HEAP_FLAG_NONE,
|
||||||
&edram_buffer_desc, edram_buffer_state_, nullptr,
|
&edram_buffer_desc, edram_buffer_state_, nullptr,
|
||||||
IID_PPV_ARGS(&edram_buffer_)))) {
|
IID_PPV_ARGS(&edram_buffer_)))) {
|
||||||
XELOGE("Failed to create the EDRAM buffer");
|
XELOGE("Failed to create the EDRAM buffer");
|
||||||
|
@ -1451,10 +1456,11 @@ bool RenderTargetCache::InitializeTraceSubmitDownloads() {
|
||||||
ui::d3d12::util::FillBufferResourceDesc(edram_snapshot_download_buffer_desc,
|
ui::d3d12::util::FillBufferResourceDesc(edram_snapshot_download_buffer_desc,
|
||||||
xenos::kEdramSizeBytes,
|
xenos::kEdramSizeBytes,
|
||||||
D3D12_RESOURCE_FLAG_NONE);
|
D3D12_RESOURCE_FLAG_NONE);
|
||||||
auto device =
|
auto& provider = command_processor_.GetD3D12Context().GetD3D12Provider();
|
||||||
command_processor_.GetD3D12Context().GetD3D12Provider().GetDevice();
|
auto device = provider.GetDevice();
|
||||||
if (FAILED(device->CreateCommittedResource(
|
if (FAILED(device->CreateCommittedResource(
|
||||||
&ui::d3d12::util::kHeapPropertiesReadback, D3D12_HEAP_FLAG_NONE,
|
&ui::d3d12::util::kHeapPropertiesReadback,
|
||||||
|
provider.GetHeapFlagCreateNotZeroed(),
|
||||||
&edram_snapshot_download_buffer_desc,
|
&edram_snapshot_download_buffer_desc,
|
||||||
D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
|
D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
|
||||||
IID_PPV_ARGS(&edram_snapshot_download_buffer_)))) {
|
IID_PPV_ARGS(&edram_snapshot_download_buffer_)))) {
|
||||||
|
@ -1493,10 +1499,9 @@ void RenderTargetCache::RestoreEdramSnapshot(const void* snapshot) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto& provider = command_processor_.GetD3D12Context().GetD3D12Provider();
|
auto& provider = command_processor_.GetD3D12Context().GetD3D12Provider();
|
||||||
auto device = provider.GetDevice();
|
|
||||||
if (!edram_snapshot_restore_pool_) {
|
if (!edram_snapshot_restore_pool_) {
|
||||||
edram_snapshot_restore_pool_ =
|
edram_snapshot_restore_pool_ =
|
||||||
std::make_unique<ui::d3d12::UploadBufferPool>(device,
|
std::make_unique<ui::d3d12::UploadBufferPool>(provider,
|
||||||
xenos::kEdramSizeBytes);
|
xenos::kEdramSizeBytes);
|
||||||
}
|
}
|
||||||
ID3D12Resource* upload_buffer;
|
ID3D12Resource* upload_buffer;
|
||||||
|
@ -1603,14 +1608,15 @@ bool RenderTargetCache::MakeHeapResident(uint32_t heap_index) {
|
||||||
if (heaps_[heap_index] != nullptr) {
|
if (heaps_[heap_index] != nullptr) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
auto device =
|
auto& provider = command_processor_.GetD3D12Context().GetD3D12Provider();
|
||||||
command_processor_.GetD3D12Context().GetD3D12Provider().GetDevice();
|
auto device = provider.GetDevice();
|
||||||
D3D12_HEAP_DESC heap_desc = {};
|
D3D12_HEAP_DESC heap_desc = {};
|
||||||
heap_desc.SizeInBytes = kHeap4MBPages << 22;
|
heap_desc.SizeInBytes = kHeap4MBPages << 22;
|
||||||
heap_desc.Properties.Type = D3D12_HEAP_TYPE_DEFAULT;
|
heap_desc.Properties.Type = D3D12_HEAP_TYPE_DEFAULT;
|
||||||
// TODO(Triang3l): If real MSAA is added, alignment must be 4 MB.
|
// TODO(Triang3l): If real MSAA is added, alignment must be 4 MB.
|
||||||
heap_desc.Alignment = 0;
|
heap_desc.Alignment = 0;
|
||||||
heap_desc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES;
|
heap_desc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES |
|
||||||
|
provider.GetHeapFlagCreateNotZeroed();
|
||||||
if (FAILED(
|
if (FAILED(
|
||||||
device->CreateHeap(&heap_desc, IID_PPV_ARGS(&heaps_[heap_index])))) {
|
device->CreateHeap(&heap_desc, IID_PPV_ARGS(&heaps_[heap_index])))) {
|
||||||
XELOGE("Failed to create a {} MB heap for render targets",
|
XELOGE("Failed to create a {} MB heap for render targets",
|
||||||
|
@ -1756,8 +1762,9 @@ RenderTargetCache::RenderTarget* RenderTargetCache::FindOrCreateRenderTarget(
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (FAILED(device->CreateCommittedResource(
|
if (FAILED(device->CreateCommittedResource(
|
||||||
&ui::d3d12::util::kHeapPropertiesDefault, D3D12_HEAP_FLAG_NONE,
|
&ui::d3d12::util::kHeapPropertiesDefault,
|
||||||
&resource_desc, state, nullptr, IID_PPV_ARGS(&resource)))) {
|
provider.GetHeapFlagCreateNotZeroed(), &resource_desc, state, nullptr,
|
||||||
|
IID_PPV_ARGS(&resource)))) {
|
||||||
XELOGE(
|
XELOGE(
|
||||||
"Failed to create a committed resource for {}x{} {} render target with "
|
"Failed to create a committed resource for {}x{} {} render target with "
|
||||||
"format {}",
|
"format {}",
|
||||||
|
|
|
@ -73,8 +73,9 @@ bool SharedMemory::Initialize() {
|
||||||
"resources yet.");
|
"resources yet.");
|
||||||
}
|
}
|
||||||
if (FAILED(device->CreateCommittedResource(
|
if (FAILED(device->CreateCommittedResource(
|
||||||
&ui::d3d12::util::kHeapPropertiesDefault, D3D12_HEAP_FLAG_NONE,
|
&ui::d3d12::util::kHeapPropertiesDefault,
|
||||||
&buffer_desc, buffer_state_, nullptr, IID_PPV_ARGS(&buffer_)))) {
|
provider.GetHeapFlagCreateNotZeroed(), &buffer_desc, buffer_state_,
|
||||||
|
nullptr, IID_PPV_ARGS(&buffer_)))) {
|
||||||
XELOGE("Shared memory: Failed to create the 512 MB buffer");
|
XELOGE("Shared memory: Failed to create the 512 MB buffer");
|
||||||
Shutdown();
|
Shutdown();
|
||||||
return false;
|
return false;
|
||||||
|
@ -153,7 +154,7 @@ bool SharedMemory::Initialize() {
|
||||||
system_page_flags_.resize((page_count_ + 63) / 64);
|
system_page_flags_.resize((page_count_ + 63) / 64);
|
||||||
|
|
||||||
upload_buffer_pool_ = std::make_unique<ui::d3d12::UploadBufferPool>(
|
upload_buffer_pool_ = std::make_unique<ui::d3d12::UploadBufferPool>(
|
||||||
device,
|
provider,
|
||||||
xe::align(uint32_t(4 * 1024 * 1024), uint32_t(1) << page_size_log2_));
|
xe::align(uint32_t(4 * 1024 * 1024), uint32_t(1) << page_size_log2_));
|
||||||
|
|
||||||
memory_invalidation_callback_handle_ =
|
memory_invalidation_callback_handle_ =
|
||||||
|
@ -370,7 +371,8 @@ bool SharedMemory::EnsureTilesResident(uint32_t start, uint32_t length) {
|
||||||
D3D12_HEAP_DESC heap_desc = {};
|
D3D12_HEAP_DESC heap_desc = {};
|
||||||
heap_desc.SizeInBytes = kHeapSize;
|
heap_desc.SizeInBytes = kHeapSize;
|
||||||
heap_desc.Properties.Type = D3D12_HEAP_TYPE_DEFAULT;
|
heap_desc.Properties.Type = D3D12_HEAP_TYPE_DEFAULT;
|
||||||
heap_desc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS;
|
heap_desc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS |
|
||||||
|
provider.GetHeapFlagCreateNotZeroed();
|
||||||
if (FAILED(device->CreateHeap(&heap_desc, IID_PPV_ARGS(&heaps_[i])))) {
|
if (FAILED(device->CreateHeap(&heap_desc, IID_PPV_ARGS(&heaps_[i])))) {
|
||||||
XELOGE("Shared memory: Failed to create a tile heap");
|
XELOGE("Shared memory: Failed to create a tile heap");
|
||||||
return false;
|
return false;
|
||||||
|
@ -890,11 +892,12 @@ bool SharedMemory::InitializeTraceSubmitDownloads() {
|
||||||
ui::d3d12::util::FillBufferResourceDesc(
|
ui::d3d12::util::FillBufferResourceDesc(
|
||||||
gpu_written_buffer_desc, gpu_written_page_count << page_size_log2_,
|
gpu_written_buffer_desc, gpu_written_page_count << page_size_log2_,
|
||||||
D3D12_RESOURCE_FLAG_NONE);
|
D3D12_RESOURCE_FLAG_NONE);
|
||||||
auto device =
|
auto& provider = command_processor_.GetD3D12Context().GetD3D12Provider();
|
||||||
command_processor_.GetD3D12Context().GetD3D12Provider().GetDevice();
|
auto device = provider.GetDevice();
|
||||||
if (FAILED(device->CreateCommittedResource(
|
if (FAILED(device->CreateCommittedResource(
|
||||||
&ui::d3d12::util::kHeapPropertiesReadback, D3D12_HEAP_FLAG_NONE,
|
&ui::d3d12::util::kHeapPropertiesReadback,
|
||||||
&gpu_written_buffer_desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
|
provider.GetHeapFlagCreateNotZeroed(), &gpu_written_buffer_desc,
|
||||||
|
D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
|
||||||
IID_PPV_ARGS(&trace_gpu_written_buffer_)))) {
|
IID_PPV_ARGS(&trace_gpu_written_buffer_)))) {
|
||||||
XELOGE(
|
XELOGE(
|
||||||
"Shared memory: Failed to create a {} KB GPU-written memory download "
|
"Shared memory: Failed to create a {} KB GPU-written memory download "
|
||||||
|
|
|
@ -1633,7 +1633,8 @@ bool TextureCache::EnsureScaledResolveBufferResident(uint32_t start_unscaled,
|
||||||
D3D12_HEAP_DESC heap_desc = {};
|
D3D12_HEAP_DESC heap_desc = {};
|
||||||
heap_desc.SizeInBytes = kScaledResolveHeapSize;
|
heap_desc.SizeInBytes = kScaledResolveHeapSize;
|
||||||
heap_desc.Properties.Type = D3D12_HEAP_TYPE_DEFAULT;
|
heap_desc.Properties.Type = D3D12_HEAP_TYPE_DEFAULT;
|
||||||
heap_desc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS;
|
heap_desc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS |
|
||||||
|
provider.GetHeapFlagCreateNotZeroed();
|
||||||
if (FAILED(device->CreateHeap(&heap_desc,
|
if (FAILED(device->CreateHeap(&heap_desc,
|
||||||
IID_PPV_ARGS(&scaled_resolve_heaps_[i])))) {
|
IID_PPV_ARGS(&scaled_resolve_heaps_[i])))) {
|
||||||
XELOGE("Texture cache: Failed to create a scaled resolve tile heap");
|
XELOGE("Texture cache: Failed to create a scaled resolve tile heap");
|
||||||
|
@ -1953,14 +1954,15 @@ TextureCache::Texture* TextureCache::FindOrCreateTexture(TextureKey key) {
|
||||||
// Untiling through a buffer instead of using unordered access because copying
|
// Untiling through a buffer instead of using unordered access because copying
|
||||||
// is not done that often.
|
// is not done that often.
|
||||||
desc.Flags = D3D12_RESOURCE_FLAG_NONE;
|
desc.Flags = D3D12_RESOURCE_FLAG_NONE;
|
||||||
auto device =
|
auto& provider = command_processor_.GetD3D12Context().GetD3D12Provider();
|
||||||
command_processor_.GetD3D12Context().GetD3D12Provider().GetDevice();
|
auto device = provider.GetDevice();
|
||||||
// Assuming untiling will be the next operation.
|
// Assuming untiling will be the next operation.
|
||||||
D3D12_RESOURCE_STATES state = D3D12_RESOURCE_STATE_COPY_DEST;
|
D3D12_RESOURCE_STATES state = D3D12_RESOURCE_STATE_COPY_DEST;
|
||||||
ID3D12Resource* resource;
|
ID3D12Resource* resource;
|
||||||
if (FAILED(device->CreateCommittedResource(
|
if (FAILED(device->CreateCommittedResource(
|
||||||
&ui::d3d12::util::kHeapPropertiesDefault, D3D12_HEAP_FLAG_NONE, &desc,
|
&ui::d3d12::util::kHeapPropertiesDefault,
|
||||||
state, nullptr, IID_PPV_ARGS(&resource)))) {
|
provider.GetHeapFlagCreateNotZeroed(), &desc, state, nullptr,
|
||||||
|
IID_PPV_ARGS(&resource)))) {
|
||||||
LogTextureKeyAction(key, "Failed to create");
|
LogTextureKeyAction(key, "Failed to create");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ class D3D12ImmediateTexture : public ImmediateTexture {
|
||||||
ImmediateTextureFilter filter, bool repeat);
|
ImmediateTextureFilter filter, bool repeat);
|
||||||
~D3D12ImmediateTexture() override;
|
~D3D12ImmediateTexture() override;
|
||||||
|
|
||||||
bool Initialize(ID3D12Device* device);
|
bool Initialize(D3D12Provider& provider);
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
ID3D12Resource* GetResource() const { return resource_; }
|
ID3D12Resource* GetResource() const { return resource_; }
|
||||||
|
@ -59,7 +59,7 @@ D3D12ImmediateTexture::D3D12ImmediateTexture(uint32_t width, uint32_t height,
|
||||||
|
|
||||||
D3D12ImmediateTexture::~D3D12ImmediateTexture() { Shutdown(); }
|
D3D12ImmediateTexture::~D3D12ImmediateTexture() { Shutdown(); }
|
||||||
|
|
||||||
bool D3D12ImmediateTexture::Initialize(ID3D12Device* device) {
|
bool D3D12ImmediateTexture::Initialize(D3D12Provider& provider) {
|
||||||
// The first operation will likely be copying the contents.
|
// The first operation will likely be copying the contents.
|
||||||
state_ = D3D12_RESOURCE_STATE_COPY_DEST;
|
state_ = D3D12_RESOURCE_STATE_COPY_DEST;
|
||||||
|
|
||||||
|
@ -75,9 +75,9 @@ bool D3D12ImmediateTexture::Initialize(ID3D12Device* device) {
|
||||||
resource_desc.SampleDesc.Quality = 0;
|
resource_desc.SampleDesc.Quality = 0;
|
||||||
resource_desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
|
resource_desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
|
||||||
resource_desc.Flags = D3D12_RESOURCE_FLAG_NONE;
|
resource_desc.Flags = D3D12_RESOURCE_FLAG_NONE;
|
||||||
if (FAILED(device->CreateCommittedResource(
|
if (FAILED(provider.GetDevice()->CreateCommittedResource(
|
||||||
&util::kHeapPropertiesDefault, D3D12_HEAP_FLAG_NONE, &resource_desc,
|
&util::kHeapPropertiesDefault, provider.GetHeapFlagCreateNotZeroed(),
|
||||||
state_, nullptr, IID_PPV_ARGS(&resource_)))) {
|
&resource_desc, state_, nullptr, IID_PPV_ARGS(&resource_)))) {
|
||||||
XELOGE("Failed to create a {}x{} texture for immediate drawing", width,
|
XELOGE("Failed to create a {}x{} texture for immediate drawing", width,
|
||||||
height);
|
height);
|
||||||
return false;
|
return false;
|
||||||
|
@ -288,7 +288,7 @@ bool D3D12ImmediateDrawer::Initialize() {
|
||||||
|
|
||||||
// Create pools for draws.
|
// Create pools for draws.
|
||||||
vertex_buffer_pool_ =
|
vertex_buffer_pool_ =
|
||||||
std::make_unique<UploadBufferPool>(device, 2 * 1024 * 1024);
|
std::make_unique<UploadBufferPool>(provider, 2 * 1024 * 1024);
|
||||||
texture_descriptor_pool_ = std::make_unique<DescriptorHeapPool>(
|
texture_descriptor_pool_ = std::make_unique<DescriptorHeapPool>(
|
||||||
device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 2048);
|
device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 2048);
|
||||||
texture_descriptor_pool_heap_index_ = DescriptorHeapPool::kHeapIndexInvalid;
|
texture_descriptor_pool_heap_index_ = DescriptorHeapPool::kHeapIndexInvalid;
|
||||||
|
@ -326,7 +326,7 @@ std::unique_ptr<ImmediateTexture> D3D12ImmediateDrawer::CreateTexture(
|
||||||
const uint8_t* data) {
|
const uint8_t* data) {
|
||||||
auto texture =
|
auto texture =
|
||||||
std::make_unique<D3D12ImmediateTexture>(width, height, filter, repeat);
|
std::make_unique<D3D12ImmediateTexture>(width, height, filter, repeat);
|
||||||
texture->Initialize(context_.GetD3D12Provider().GetDevice());
|
texture->Initialize(context_.GetD3D12Provider());
|
||||||
if (data != nullptr) {
|
if (data != nullptr) {
|
||||||
UpdateTexture(texture.get(), data);
|
UpdateTexture(texture.get(), data);
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,8 @@ void D3D12ImmediateDrawer::UpdateTexture(ImmediateTexture* texture,
|
||||||
}
|
}
|
||||||
uint32_t width = d3d_texture->width, height = d3d_texture->height;
|
uint32_t width = d3d_texture->width, height = d3d_texture->height;
|
||||||
|
|
||||||
auto device = context_.GetD3D12Provider().GetDevice();
|
auto& provider = context_.GetD3D12Provider();
|
||||||
|
auto device = provider.GetDevice();
|
||||||
|
|
||||||
// Create and fill the upload buffer.
|
// Create and fill the upload buffer.
|
||||||
D3D12_RESOURCE_DESC texture_desc = texture_resource->GetDesc();
|
D3D12_RESOURCE_DESC texture_desc = texture_resource->GetDesc();
|
||||||
|
@ -356,8 +357,9 @@ void D3D12ImmediateDrawer::UpdateTexture(ImmediateTexture* texture,
|
||||||
D3D12_RESOURCE_FLAG_NONE);
|
D3D12_RESOURCE_FLAG_NONE);
|
||||||
ID3D12Resource* buffer;
|
ID3D12Resource* buffer;
|
||||||
if (FAILED(device->CreateCommittedResource(
|
if (FAILED(device->CreateCommittedResource(
|
||||||
&util::kHeapPropertiesUpload, D3D12_HEAP_FLAG_NONE, &buffer_desc,
|
&util::kHeapPropertiesUpload, provider.GetHeapFlagCreateNotZeroed(),
|
||||||
D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, IID_PPV_ARGS(&buffer)))) {
|
&buffer_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
|
||||||
|
IID_PPV_ARGS(&buffer)))) {
|
||||||
XELOGE(
|
XELOGE(
|
||||||
"Failed to create an upload buffer for a {}x{} texture for "
|
"Failed to create an upload buffer for a {}x{} texture for "
|
||||||
"immediate drawing",
|
"immediate drawing",
|
||||||
|
|
|
@ -409,17 +409,29 @@ bool D3D12Provider::Initialize() {
|
||||||
virtual_address_bits_per_resource_ =
|
virtual_address_bits_per_resource_ =
|
||||||
virtual_address_support.MaxGPUVirtualAddressBitsPerResource;
|
virtual_address_support.MaxGPUVirtualAddressBitsPerResource;
|
||||||
}
|
}
|
||||||
|
// D3D12_HEAP_FLAG_CREATE_NOT_ZEROED requires Windows 10 2004 (indicated by
|
||||||
|
// the availability of ID3D12Device8 or D3D12_FEATURE_D3D12_OPTIONS7).
|
||||||
|
heap_flag_create_not_zeroed_ = D3D12_HEAP_FLAG_NONE;
|
||||||
|
D3D12_FEATURE_DATA_D3D12_OPTIONS7 options7;
|
||||||
|
if (SUCCEEDED(device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS7,
|
||||||
|
&options7, sizeof(options7)))) {
|
||||||
|
heap_flag_create_not_zeroed_ = D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
|
||||||
|
}
|
||||||
XELOGD3D(
|
XELOGD3D(
|
||||||
"Direct3D 12 device features:\n"
|
"Direct3D 12 device and OS features:\n"
|
||||||
"Max GPU virtual address bits per resource: {}\n"
|
"* Max GPU virtual address bits per resource: {}\n"
|
||||||
"Programmable sample positions: tier {}\n"
|
"* Programmable sample positions: tier {}\n"
|
||||||
"Rasterizer-ordered views: {}\n"
|
"* Rasterizer-ordered views: {}\n"
|
||||||
"Resource binding: tier {}\n"
|
"* Resource binding: tier {}\n"
|
||||||
"Tiled resources: tier {}\n",
|
"* Tiled resources: tier {}\n"
|
||||||
|
"* Non-zeroed heap creation: {}\n",
|
||||||
virtual_address_bits_per_resource_,
|
virtual_address_bits_per_resource_,
|
||||||
uint32_t(programmable_sample_positions_tier_),
|
uint32_t(programmable_sample_positions_tier_),
|
||||||
rasterizer_ordered_views_supported_ ? "yes" : "no",
|
rasterizer_ordered_views_supported_ ? "yes" : "no",
|
||||||
uint32_t(resource_binding_tier_), uint32_t(tiled_resources_tier_));
|
uint32_t(resource_binding_tier_), uint32_t(tiled_resources_tier_),
|
||||||
|
(heap_flag_create_not_zeroed_ & D3D12_HEAP_FLAG_CREATE_NOT_ZEROED)
|
||||||
|
? "yes"
|
||||||
|
: "no");
|
||||||
|
|
||||||
// Get the graphics analysis interface, will silently fail if PIX is not
|
// Get the graphics analysis interface, will silently fail if PIX is not
|
||||||
// attached.
|
// attached.
|
||||||
|
|
|
@ -84,6 +84,9 @@ class D3D12Provider : public GraphicsProvider {
|
||||||
uint32_t GetVirtualAddressBitsPerResource() const {
|
uint32_t GetVirtualAddressBitsPerResource() const {
|
||||||
return virtual_address_bits_per_resource_;
|
return virtual_address_bits_per_resource_;
|
||||||
}
|
}
|
||||||
|
D3D12_HEAP_FLAGS GetHeapFlagCreateNotZeroed() const {
|
||||||
|
return heap_flag_create_not_zeroed_;
|
||||||
|
}
|
||||||
|
|
||||||
// Proxies for Direct3D 12 functions since they are loaded dynamically.
|
// Proxies for Direct3D 12 functions since they are loaded dynamically.
|
||||||
inline HRESULT SerializeRootSignature(const D3D12_ROOT_SIGNATURE_DESC* desc,
|
inline HRESULT SerializeRootSignature(const D3D12_ROOT_SIGNATURE_DESC* desc,
|
||||||
|
@ -164,6 +167,7 @@ class D3D12Provider : public GraphicsProvider {
|
||||||
D3D12_RESOURCE_BINDING_TIER resource_binding_tier_;
|
D3D12_RESOURCE_BINDING_TIER resource_binding_tier_;
|
||||||
D3D12_TILED_RESOURCES_TIER tiled_resources_tier_;
|
D3D12_TILED_RESOURCES_TIER tiled_resources_tier_;
|
||||||
uint32_t virtual_address_bits_per_resource_;
|
uint32_t virtual_address_bits_per_resource_;
|
||||||
|
D3D12_HEAP_FLAGS heap_flag_create_not_zeroed_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace d3d12
|
} // namespace d3d12
|
||||||
|
|
|
@ -19,8 +19,8 @@ namespace xe {
|
||||||
namespace ui {
|
namespace ui {
|
||||||
namespace d3d12 {
|
namespace d3d12 {
|
||||||
|
|
||||||
UploadBufferPool::UploadBufferPool(ID3D12Device* device, uint32_t page_size)
|
UploadBufferPool::UploadBufferPool(D3D12Provider& provider, uint32_t page_size)
|
||||||
: device_(device), page_size_(page_size) {}
|
: provider_(provider), page_size_(page_size) {}
|
||||||
|
|
||||||
UploadBufferPool::~UploadBufferPool() { ClearCache(); }
|
UploadBufferPool::~UploadBufferPool() { ClearCache(); }
|
||||||
|
|
||||||
|
@ -101,9 +101,10 @@ uint8_t* UploadBufferPool::Request(uint64_t submission_index, uint32_t size,
|
||||||
util::FillBufferResourceDesc(new_buffer_desc, page_size_,
|
util::FillBufferResourceDesc(new_buffer_desc, page_size_,
|
||||||
D3D12_RESOURCE_FLAG_NONE);
|
D3D12_RESOURCE_FLAG_NONE);
|
||||||
ID3D12Resource* new_buffer;
|
ID3D12Resource* new_buffer;
|
||||||
if (FAILED(device_->CreateCommittedResource(
|
if (FAILED(provider_.GetDevice()->CreateCommittedResource(
|
||||||
&util::kHeapPropertiesUpload, D3D12_HEAP_FLAG_NONE,
|
&util::kHeapPropertiesUpload,
|
||||||
&new_buffer_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
|
provider_.GetHeapFlagCreateNotZeroed(), &new_buffer_desc,
|
||||||
|
D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
|
||||||
IID_PPV_ARGS(&new_buffer)))) {
|
IID_PPV_ARGS(&new_buffer)))) {
|
||||||
XELOGE("Failed to create a D3D upload buffer with {} bytes",
|
XELOGE("Failed to create a D3D upload buffer with {} bytes",
|
||||||
page_size_);
|
page_size_);
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#include "xenia/ui/d3d12/d3d12_api.h"
|
#include "xenia/ui/d3d12/d3d12_provider.h"
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
@ -23,7 +23,7 @@ namespace d3d12 {
|
||||||
|
|
||||||
class UploadBufferPool {
|
class UploadBufferPool {
|
||||||
public:
|
public:
|
||||||
UploadBufferPool(ID3D12Device* device, uint32_t page_size);
|
UploadBufferPool(D3D12Provider& provider, uint32_t page_size);
|
||||||
~UploadBufferPool();
|
~UploadBufferPool();
|
||||||
|
|
||||||
void Reclaim(uint64_t completed_submission_index);
|
void Reclaim(uint64_t completed_submission_index);
|
||||||
|
@ -41,7 +41,7 @@ class UploadBufferPool {
|
||||||
D3D12_GPU_VIRTUAL_ADDRESS* gpu_address_out);
|
D3D12_GPU_VIRTUAL_ADDRESS* gpu_address_out);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ID3D12Device* device_;
|
D3D12Provider& provider_;
|
||||||
uint32_t page_size_;
|
uint32_t page_size_;
|
||||||
|
|
||||||
struct Page {
|
struct Page {
|
||||||
|
|
Loading…
Reference in New Issue