Skip to content

Commit

Permalink
Merge pull request #860 from SunDaw/sample-fixes
Browse files Browse the repository at this point in the history
fixes to make most Kinc-samples work with clang/MinGW
  • Loading branch information
RobDangerous authored Feb 17, 2024
2 parents 6c680d4 + 9cef1af commit 9f1a109
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ void kinc_g5_command_list_upload_texture(kinc_g5_command_list_t *list, kinc_g5_t
}

D3D12_RESOURCE_DESC Desc = texture->impl.image->GetDesc();
ID3D12Device *device;
ID3D12Device *device = NULL;
texture->impl.image->GetDevice(IID_GRAPHICS_PPV_ARGS(&device));
D3D12_PLACED_SUBRESOURCE_FOOTPRINT footprint;
device->GetCopyableFootprints(&Desc, 0, 1, 0, &footprint, NULL, NULL, NULL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ void kinc_g5_compute_shader_init(kinc_g5_compute_shader *shader, void *_data, in
}
kinc_compute_internal_shader_constant_t constant;
constant.hash = kinc_internal_hash_name(name);
constant.offset = *(uint32_t *)&data[index];
memcpy(&constant.offset, &data[index], sizeof(constant.offset));
index += 4;
constant.size = *(uint32_t *)&data[index];
memcpy(&constant.size, &data[index], sizeof(constant.size));
index += 4;
constant.columns = data[index];
index += 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ static void render_target_init(kinc_g5_render_target_t *render_target, int width
heapDesc.NumDescriptors = 1;
heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
device->CreateDescriptorHeap(&heapDesc, IID_GRAPHICS_PPV_ARGS(&render_target->impl.renderTargetDescriptorHeap));
kinc_microsoft_affirm(device->CreateDescriptorHeap(&heapDesc, IID_GRAPHICS_PPV_ARGS(&render_target->impl.renderTargetDescriptorHeap)));

if (framebuffer_index >= 0) {
#ifdef KORE_DIRECT3D_HAS_NO_SWAPCHAIN
render_target->impl.renderTarget = swapChainRenderTargets[framebuffer_index];
#else
IDXGISwapChain *swapChain = kinc_dx_current_window()->swapChain;
swapChain->GetBuffer(framebuffer_index, IID_PPV_ARGS(&render_target->impl.renderTarget));
kinc_microsoft_affirm(swapChain->GetBuffer(framebuffer_index, IID_PPV_ARGS(&render_target->impl.renderTarget)));
wchar_t buffer[128];
wsprintf(buffer, L"Backbuffer (index %i)", framebuffer_index);
render_target->impl.renderTarget->SetName(buffer);
Expand Down Expand Up @@ -143,7 +143,7 @@ static void render_target_init(kinc_g5_render_target_t *render_target, int width
descriptorHeapDesc.NodeMask = 0;
descriptorHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;

device->CreateDescriptorHeap(&descriptorHeapDesc, IID_GRAPHICS_PPV_ARGS(&render_target->impl.srvDescriptorHeap));
kinc_microsoft_affirm(device->CreateDescriptorHeap(&descriptorHeapDesc, IID_GRAPHICS_PPV_ARGS(&render_target->impl.srvDescriptorHeap)));

D3D12_SHADER_RESOURCE_VIEW_DESC shaderResourceViewDesc;
ZeroMemory(&shaderResourceViewDesc, sizeof(shaderResourceViewDesc));
Expand All @@ -162,7 +162,7 @@ static void render_target_init(kinc_g5_render_target_t *render_target, int width
dsvHeapDesc.NumDescriptors = 1;
dsvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV;
dsvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
device->CreateDescriptorHeap(&dsvHeapDesc, IID_GRAPHICS_PPV_ARGS(&render_target->impl.depthStencilDescriptorHeap));
kinc_microsoft_affirm(device->CreateDescriptorHeap(&dsvHeapDesc, IID_GRAPHICS_PPV_ARGS(&render_target->impl.depthStencilDescriptorHeap)));

D3D12_RESOURCE_DESC depthTexture;
depthTexture.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
Expand Down Expand Up @@ -211,7 +211,7 @@ static void render_target_init(kinc_g5_render_target_t *render_target, int width
srvDepthHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
srvDepthHeapDesc.NodeMask = 0;
srvDepthHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
device->CreateDescriptorHeap(&srvDepthHeapDesc, IID_GRAPHICS_PPV_ARGS(&render_target->impl.srvDepthDescriptorHeap));
kinc_microsoft_affirm(device->CreateDescriptorHeap(&srvDepthHeapDesc, IID_GRAPHICS_PPV_ARGS(&render_target->impl.srvDepthDescriptorHeap)));

D3D12_SHADER_RESOURCE_VIEW_DESC srvDepthViewDesc;
ZeroMemory(&srvDepthViewDesc, sizeof(srvDepthViewDesc));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ void kinc_g5_shader_init(kinc_g5_shader_t *shader, const void *_data, size_t len
break;
}
ShaderConstant constant;
constant.offset = *(uint32_t *)&data[index];
memcpy(&constant.offset, &data[index], sizeof(constant.offset));
index += 4;
constant.size = *(uint32_t *)&data[index];
memcpy(&constant.size, &data[index], sizeof(constant.size));
index += 4;
#ifdef KORE_WINDOWS
index += 2; // columns and rows
Expand Down
2 changes: 1 addition & 1 deletion Sources/kinc/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static void *buffer_malloc(size_t size) {
kinc_log(KINC_LOG_LEVEL_ERROR, "Not enough memory on image.c Buffer.");
return NULL;
}
*(size_t *)current = size;
memcpy(current, &size, sizeof(*current));
last_allocated_pointer = current + sizeof(size_t);
return current + sizeof(size_t);
}
Expand Down

0 comments on commit 9f1a109

Please sign in to comment.