Skip to content

Commit

Permalink
Set an optimized clear value
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Sep 17, 2024
1 parent ec9a93a commit eba9a51
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,16 +470,30 @@ void kope_d3d12_device_create_texture(kope_g5_device *device, const kope_g5_text
desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
desc.Flags = D3D12_RESOURCE_FLAG_NONE;

D3D12_CLEAR_VALUE optimizedClearValue;
D3D12_CLEAR_VALUE *optimizedClearValuePointer = NULL;

if ((parameters->usage & KONG_G5_TEXTURE_USAGE_RENDER_ATTACHMENT) != 0) {
desc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;

optimizedClearValue.Color[0] = 0.0f;
optimizedClearValue.Color[1] = 0.0f;
optimizedClearValue.Color[2] = 0.0f;
optimizedClearValue.Color[3] = 1.0f;
optimizedClearValue.DepthStencil.Depth = 0.0f;
optimizedClearValue.DepthStencil.Stencil = 0;
optimizedClearValue.Format = format;

optimizedClearValuePointer = &optimizedClearValue;
}

if ((parameters->usage & KONG_G5_TEXTURE_USAGE_READ_WRITE) != 0) {
desc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
}

kinc_microsoft_affirm(device->d3d12.device->CreateCommittedResource(
&heap_properties, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, NULL, IID_GRAPHICS_PPV_ARGS(&texture->d3d12.resource)));
kinc_microsoft_affirm(device->d3d12.device->CreateCommittedResource(&heap_properties, D3D12_HEAP_FLAG_NONE, &desc,
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, optimizedClearValuePointer,
IID_GRAPHICS_PPV_ARGS(&texture->d3d12.resource)));

texture->d3d12.resource_state = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
texture->d3d12.format = format;
Expand Down

0 comments on commit eba9a51

Please sign in to comment.