Skip to content

Commit

Permalink
fix clang-cl errors on Windows D3D12 target
Browse files Browse the repository at this point in the history
  • Loading branch information
SunDaw committed Feb 11, 2024
1 parent 142c80b commit fc8390e
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
uint32_t kinc_internal_hash_name(unsigned char *str) {
unsigned long hash = 5381;
int c;
while (c = *str++) {
while ((c = *str++)) {
hash = hash * 33 ^ c;
}
return hash;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <Kinc/Graphics5/ConstantBuffer.h>
#include <kinc/graphics5/constantbuffer.h>

#include <kinc/backend/SystemMicrosoft.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,8 @@ void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipe) {
case KINC_G4_VERTEX_DATA_U32_4X:
vertexDesc[curAttr].Format = DXGI_FORMAT_R32G32B32A32_UINT;
break;
default:
break;
}
curAttr++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ typedef struct {
} AttributeLocation5Impl;

struct kinc_g5_pipeline;
struct kinc_g5_command_list;

void kinc_g5_internal_setConstants(struct kinc_g5_command_list *commandList, struct kinc_g5_pipeline *pipeline);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ void kinc_raytrace_pipeline_init(kinc_raytrace_pipeline_t *pipeline, kinc_g5_com
kinc_g5_constant_buffer_t *constant_buffer) {
pipeline->_constant_buffer = constant_buffer;
// Descriptor heap
D3D12_DESCRIPTOR_HEAP_DESC descriptorHeapDesc = {0};
D3D12_DESCRIPTOR_HEAP_DESC descriptorHeapDesc;
ZeroMemory(&descriptorHeapDesc, sizeof(descriptorHeapDesc));
// Allocate a heap for 3 descriptors:
// 2 - bottom and top level acceleration structure
// 1 - raytracing output texture SRV
Expand Down Expand Up @@ -72,7 +73,8 @@ void kinc_raytrace_pipeline_init(kinc_raytrace_pipeline_t *pipeline, kinc_g5_com
device->CreateRootSignature(1, blob->GetBufferPointer(), blob->GetBufferSize(), IID_GRAPHICS_PPV_ARGS(&dxrRootSignature));

// Pipeline
D3D12_STATE_OBJECT_DESC raytracingPipeline = {0};
D3D12_STATE_OBJECT_DESC raytracingPipeline;
ZeroMemory(&raytracingPipeline, sizeof(raytracingPipeline));
raytracingPipeline.Type = D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE;

D3D12_SHADER_BYTECODE shaderBytecode = {0};
Expand Down Expand Up @@ -130,7 +132,8 @@ void kinc_raytrace_pipeline_init(kinc_raytrace_pipeline_t *pipeline, kinc_g5_com
{
UINT size = shaderIdSize + constant_buffer->impl.mySize;
UINT shaderRecordSize = (size + (align - 1)) & ~(align - 1);
D3D12_RESOURCE_DESC bufferDesc = {0};
D3D12_RESOURCE_DESC bufferDesc;
ZeroMemory(&bufferDesc, sizeof(bufferDesc));
bufferDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
bufferDesc.Width = shaderRecordSize;
bufferDesc.Height = 1;
Expand All @@ -140,7 +143,8 @@ void kinc_raytrace_pipeline_init(kinc_raytrace_pipeline_t *pipeline, kinc_g5_com
bufferDesc.SampleDesc.Count = 1;
bufferDesc.SampleDesc.Quality = 0;
bufferDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
D3D12_HEAP_PROPERTIES uploadHeapProperties = {0};
D3D12_HEAP_PROPERTIES uploadHeapProperties;
ZeroMemory(&uploadHeapProperties, sizeof(uploadHeapProperties));
uploadHeapProperties.Type = D3D12_HEAP_TYPE_UPLOAD;
uploadHeapProperties.CreationNodeMask = 1;
uploadHeapProperties.VisibleNodeMask = 1;
Expand Down Expand Up @@ -168,7 +172,8 @@ void kinc_raytrace_pipeline_init(kinc_raytrace_pipeline_t *pipeline, kinc_g5_com
{
UINT size = shaderIdSize;
UINT shaderRecordSize = (size + (align - 1)) & ~(align - 1);
D3D12_RESOURCE_DESC bufferDesc = {0};
D3D12_RESOURCE_DESC bufferDesc;
ZeroMemory(&bufferDesc, sizeof(bufferDesc));
bufferDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
bufferDesc.Width = shaderRecordSize;
bufferDesc.Height = 1;
Expand All @@ -178,7 +183,8 @@ void kinc_raytrace_pipeline_init(kinc_raytrace_pipeline_t *pipeline, kinc_g5_com
bufferDesc.SampleDesc.Count = 1;
bufferDesc.SampleDesc.Quality = 0;
bufferDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
D3D12_HEAP_PROPERTIES uploadHeapProperties = {0};
D3D12_HEAP_PROPERTIES uploadHeapProperties;
ZeroMemory(&uploadHeapProperties, sizeof(uploadHeapProperties));
uploadHeapProperties.Type = D3D12_HEAP_TYPE_UPLOAD;
uploadHeapProperties.CreationNodeMask = 1;
uploadHeapProperties.VisibleNodeMask = 1;
Expand All @@ -199,7 +205,8 @@ void kinc_raytrace_pipeline_init(kinc_raytrace_pipeline_t *pipeline, kinc_g5_com
{
UINT size = shaderIdSize;
UINT shaderRecordSize = (size + (align - 1)) & ~(align - 1);
D3D12_RESOURCE_DESC bufferDesc = {0};
D3D12_RESOURCE_DESC bufferDesc;
ZeroMemory(&bufferDesc, sizeof(bufferDesc));
bufferDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
bufferDesc.Width = shaderRecordSize;
bufferDesc.Height = 1;
Expand All @@ -209,7 +216,8 @@ void kinc_raytrace_pipeline_init(kinc_raytrace_pipeline_t *pipeline, kinc_g5_com
bufferDesc.SampleDesc.Count = 1;
bufferDesc.SampleDesc.Quality = 0;
bufferDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
D3D12_HEAP_PROPERTIES uploadHeapProperties = {0};
D3D12_HEAP_PROPERTIES uploadHeapProperties;
ZeroMemory(&uploadHeapProperties, sizeof(uploadHeapProperties));
uploadHeapProperties.Type = D3D12_HEAP_TYPE_UPLOAD;
uploadHeapProperties.CreationNodeMask = 1;
uploadHeapProperties.VisibleNodeMask = 1;
Expand Down Expand Up @@ -272,7 +280,8 @@ void kinc_raytrace_acceleration_structure_init(kinc_raytrace_acceleration_struct
{
UINT64 tlSize = topLevelPrebuildInfo.ScratchDataSizeInBytes;
UINT64 blSize = bottomLevelPrebuildInfo.ScratchDataSizeInBytes;
D3D12_RESOURCE_DESC bufferDesc = {0};
D3D12_RESOURCE_DESC bufferDesc;
ZeroMemory(&bufferDesc, sizeof(bufferDesc));
bufferDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
bufferDesc.Width = tlSize > blSize ? tlSize : blSize;
bufferDesc.Height = 1;
Expand All @@ -283,7 +292,8 @@ void kinc_raytrace_acceleration_structure_init(kinc_raytrace_acceleration_struct
bufferDesc.SampleDesc.Quality = 0;
bufferDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
bufferDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
D3D12_HEAP_PROPERTIES uploadHeapProperties = {0};
D3D12_HEAP_PROPERTIES uploadHeapProperties;
ZeroMemory(&uploadHeapProperties, sizeof(uploadHeapProperties));
uploadHeapProperties.Type = D3D12_HEAP_TYPE_DEFAULT;
uploadHeapProperties.CreationNodeMask = 1;
uploadHeapProperties.VisibleNodeMask = 1;
Expand Down Expand Up @@ -343,7 +353,8 @@ void kinc_raytrace_acceleration_structure_init(kinc_raytrace_acceleration_struct
instanceDesc.InstanceMask = 1;
instanceDesc.AccelerationStructure = accel->impl.bottom_level_accel->GetGPUVirtualAddress();

D3D12_RESOURCE_DESC bufferDesc = {0};
D3D12_RESOURCE_DESC bufferDesc;
ZeroMemory(&bufferDesc, sizeof(bufferDesc));
bufferDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
bufferDesc.Width = sizeof(instanceDesc);
bufferDesc.Height = 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "rendertarget.h"

#include <Kinc/Graphics5/RenderTarget.h>
#include <Kinc/Graphics5/Texture.h>
#include <kinc/graphics5/rendertarget.h>
#include <kinc/graphics5/texture.h>
#include <kinc/backend/SystemMicrosoft.h>

#ifdef KORE_WINDOWS
Expand Down Expand Up @@ -145,7 +145,8 @@ static void render_target_init(kinc_g5_render_target_t *render_target, int width

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

D3D12_SHADER_RESOURCE_VIEW_DESC shaderResourceViewDesc = {0};
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 = dxgiFormat;
Expand Down Expand Up @@ -212,7 +213,8 @@ static void render_target_init(kinc_g5_render_target_t *render_target, int width
srvDepthHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
device->CreateDescriptorHeap(&srvDepthHeapDesc, IID_GRAPHICS_PPV_ARGS(&render_target->impl.srvDepthDescriptorHeap));

D3D12_SHADER_RESOURCE_VIEW_DESC srvDepthViewDesc = {0};
D3D12_SHADER_RESOURCE_VIEW_DESC srvDepthViewDesc;
ZeroMemory(&srvDepthViewDesc, sizeof(srvDepthViewDesc));
srvDepthViewDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
srvDepthViewDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
srvDepthViewDesc.Format = DXGI_FORMAT_R32_FLOAT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ void kinc_g5_shader_init(kinc_g5_shader_t *shader, const void *_data, size_t len
case KINC_G5_SHADER_TYPE_TESSELLATION_EVALUATION:
// Microsoft::affirm(device->CreateDomainShader(this->data, this->length, nullptr, (ID3D11DomainShader**)&shader));
break;
default:
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ void kinc_g5_texture_init_from_image(kinc_g5_texture_t *texture, kinc_image_t *i

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

D3D12_SHADER_RESOURCE_VIEW_DESC shaderResourceViewDesc = {0};
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 = d3dformat;
Expand Down Expand Up @@ -337,7 +338,8 @@ void create_texture(struct kinc_g5_texture *texture, int width, int height, kinc

texture->impl.stride = (int)ceilf(uploadBufferSize / (float)(height * d3d12_textureAlignment())) * d3d12_textureAlignment();

D3D12_DESCRIPTOR_HEAP_DESC descriptorHeapDesc = {0};
D3D12_DESCRIPTOR_HEAP_DESC descriptorHeapDesc;
ZeroMemory(&descriptorHeapDesc, sizeof(descriptorHeapDesc));
descriptorHeapDesc.NumDescriptors = 1;

descriptorHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ typedef struct {
} Texture5Impl;

struct kinc_g5_texture;
struct kinc_g5_command_list;

void kinc_g5_internal_set_textures(struct kinc_g5_command_list *commandList);
void kinc_g5_internal_texture_set(struct kinc_g5_command_list *commandList, struct kinc_g5_texture *texture, int unit);
Expand Down
6 changes: 4 additions & 2 deletions Backends/System/Windows/Sources/kinc/backend/system.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ LRESULT WINAPI KoreWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L
}
break;
}
case WM_CLOSE:
case WM_CLOSE: {
int window_index = kinc_windows_window_index_from_hwnd(hWnd);
if (kinc_internal_call_close_callback(window_index)) {
kinc_window_destroy(window_index);
Expand All @@ -358,6 +358,7 @@ LRESULT WINAPI KoreWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L
}
}
return 0;
}
case WM_ERASEBKGND:
return 1;
case WM_ACTIVATE:
Expand Down Expand Up @@ -688,7 +689,7 @@ LRESULT WINAPI KoreWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L
case WM_DEVICECHANGE:
detectGamepad = true;
break;
case WM_DROPFILES:
case WM_DROPFILES: {
HDROP hDrop = (HDROP)wParam;
unsigned count = DragQueryFileW(hDrop, 0xFFFFFFFF, NULL, 0);
for (unsigned i = 0; i < count; ++i) {
Expand All @@ -700,6 +701,7 @@ LRESULT WINAPI KoreWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L
DragFinish(hDrop);
break;
}
}
return DefWindowProcW(hWnd, msg, wParam, lParam);
}

Expand Down

0 comments on commit fc8390e

Please sign in to comment.