Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Kode/Kore
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 749d8c4c227f93fb8a80af4dfa74747b0baf6e28
Choose a base ref
...
head repository: Kode/Kore
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ba12ac80e6aacdef79edaa581bc7e5acb02aee99
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Jun 22, 2024

  1. Copy the full SHA
    ba12ac8 View commit details
Showing with 39 additions and 7 deletions.
  1. +39 −7 Backends/Graphics5/Direct3D12/Sources/kinc/backend/graphics5/texture.c.h
Original file line number Diff line number Diff line change
@@ -80,7 +80,14 @@ static int formatByteSize(kinc_image_format_t format) {
}

void kinc_g5_internal_set_textures(kinc_g5_command_list_t *list) {
if (list->impl.currentRenderTargets[0] != NULL || list->impl.currentTextures[0] != NULL) {
int texture_count = 0;
for (int i = 0; i < KINC_INTERNAL_G5_TEXTURE_COUNT; ++i) {
if ((list->impl.currentRenderTargets[i] != NULL || list->impl.currentTextures[i] != NULL) && list->impl.current_samplers[i] != NULL) {
texture_count += 1;
}
}

if (texture_count > 0) {
int srvStep = device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
int samplerStep = device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);

@@ -94,15 +101,15 @@ void kinc_g5_internal_set_textures(kinc_g5_command_list_t *list) {
samplerGpu.ptr += list->impl.heapIndex * samplerStep;

for (int i = 0; i < KINC_INTERNAL_G5_TEXTURE_COUNT; ++i) {
D3D12_CPU_DESCRIPTOR_HANDLE srvCpu = list->impl.srvHeap->GetCPUDescriptorHandleForHeapStart();
D3D12_CPU_DESCRIPTOR_HANDLE samplerCpu = list->impl.samplerHeap->GetCPUDescriptorHandleForHeapStart();
srvCpu.ptr += list->impl.heapIndex * srvStep;
samplerCpu.ptr += list->impl.heapIndex * samplerStep;
++list->impl.heapIndex;

if ((list->impl.currentRenderTargets[i] != NULL || list->impl.currentTextures[i] != NULL) && list->impl.current_samplers[i] != NULL) {
ID3D12DescriptorHeap *samplerDescriptorHeap = list->impl.current_samplers[i]->impl.sampler_heap;

D3D12_CPU_DESCRIPTOR_HANDLE srvCpu = list->impl.srvHeap->GetCPUDescriptorHandleForHeapStart();
D3D12_CPU_DESCRIPTOR_HANDLE samplerCpu = list->impl.samplerHeap->GetCPUDescriptorHandleForHeapStart();
srvCpu.ptr += list->impl.heapIndex * srvStep;
samplerCpu.ptr += list->impl.heapIndex * samplerStep;
++list->impl.heapIndex;

if (list->impl.currentRenderTargets[i] != NULL) {
bool is_depth = list->impl.currentRenderTargets[i]->impl.stage_depth == i;
D3D12_CPU_DESCRIPTOR_HANDLE sourceCpu =
@@ -119,6 +126,31 @@ void kinc_g5_internal_set_textures(kinc_g5_command_list_t *list) {
D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
}
}
else {
D3D12_SHADER_RESOURCE_VIEW_DESC shaderResourceViewDesc;
ZeroMemory(&shaderResourceViewDesc, sizeof(shaderResourceViewDesc));
shaderResourceViewDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
shaderResourceViewDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
shaderResourceViewDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
shaderResourceViewDesc.Texture2D.MipLevels = 1;
shaderResourceViewDesc.Texture2D.MostDetailedMip = 0;
shaderResourceViewDesc.Texture2D.ResourceMinLODClamp = 0.0f;
device->CreateShaderResourceView(NULL, &shaderResourceViewDesc,
srvCpu);

D3D12_SAMPLER_DESC samplerDesc;
ZeroMemory(&samplerDesc, sizeof(D3D12_SAMPLER_DESC));
samplerDesc.Filter = D3D12_FILTER_MIN_MAG_MIP_POINT;
samplerDesc.AddressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
samplerDesc.AddressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
samplerDesc.AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
samplerDesc.MinLOD = 0.0f;
samplerDesc.MaxLOD = 1.0f;
samplerDesc.MipLODBias = 0.0f;
samplerDesc.MaxAnisotropy = 1;
samplerDesc.ComparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL;
device->CreateSampler(&samplerDesc, samplerCpu);
}
}

ID3D12DescriptorHeap *heaps[2] = {list->impl.srvHeap, list->impl.samplerHeap};