diff --git a/Backends/Graphics5/Direct3D12/Sources/kinc/backend/graphics5/commandlist.c.h b/Backends/Graphics5/Direct3D12/Sources/kinc/backend/graphics5/commandlist.c.h index 03446dbb6..149581ade 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kinc/backend/graphics5/commandlist.c.h +++ b/Backends/Graphics5/Direct3D12/Sources/kinc/backend/graphics5/commandlist.c.h @@ -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); diff --git a/Backends/Graphics5/Direct3D12/Sources/kinc/backend/graphics5/compute.c.h b/Backends/Graphics5/Direct3D12/Sources/kinc/backend/graphics5/compute.c.h index 88e145b45..a92d7c8bb 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kinc/backend/graphics5/compute.c.h +++ b/Backends/Graphics5/Direct3D12/Sources/kinc/backend/graphics5/compute.c.h @@ -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; diff --git a/Backends/Graphics5/Direct3D12/Sources/kinc/backend/graphics5/rendertarget.c.h b/Backends/Graphics5/Direct3D12/Sources/kinc/backend/graphics5/rendertarget.c.h index 61e73c8d4..314f4a3c7 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kinc/backend/graphics5/rendertarget.c.h +++ b/Backends/Graphics5/Direct3D12/Sources/kinc/backend/graphics5/rendertarget.c.h @@ -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); @@ -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)); @@ -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; @@ -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)); diff --git a/Backends/Graphics5/Direct3D12/Sources/kinc/backend/graphics5/shader.c.h b/Backends/Graphics5/Direct3D12/Sources/kinc/backend/graphics5/shader.c.h index 6a95e7b91..b90115975 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kinc/backend/graphics5/shader.c.h +++ b/Backends/Graphics5/Direct3D12/Sources/kinc/backend/graphics5/shader.c.h @@ -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 diff --git a/Sources/kinc/image.h b/Sources/kinc/image.h index 96616e55f..b8787733e 100644 --- a/Sources/kinc/image.h +++ b/Sources/kinc/image.h @@ -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); }