From bf450eaa493e2d13e13a3c7ce6b97343c721d4dd Mon Sep 17 00:00:00 2001 From: luboslenco Date: Tue, 11 Feb 2025 10:51:57 +0100 Subject: [PATCH] Cleanup --- .../kinc/backend/graphics5/Direct3D12.c.h | 3 - .../kinc/backend/graphics5/commandlist.c.h | 26 +- .../kinc/backend/graphics5/pipeline.c.h | 13 +- .../kinc/backend/graphics5/vertexbuffer.c.h | 2 +- .../g4ong5/kinc/backend/graphics4/G4.c.h | 52 +--- .../kinc/backend/graphics4/pipeline.c.h | 4 +- .../kinc/backend/graphics4/vertexbuffer.c.h | 21 +- .../kinc/backend/graphics4/vertexbuffer.h | 1 - .../metal/kinc/backend/graphics5/Metal.m.h | 4 - .../kinc/backend/graphics5/commandlist.m.h | 20 +- .../metal/kinc/backend/graphics5/pipeline.m.h | 12 +- .../kinc/backend/graphics5/vertexbuffer.m.h | 2 +- .../kinc/backend/graphics5/ShaderHash.c.h | 2 +- .../kinc/backend/graphics5/commandlist.c.h | 24 +- .../kinc/backend/graphics5/indexbuffer.c.h | 5 - .../kinc/backend/graphics5/pipeline.c.h | 268 +++++++++--------- .../kinc/backend/graphics5/raytrace.c.h | 4 +- .../kinc/backend/graphics5/vertexbuffer.c.h | 18 +- .../kinc/backend/graphics5/vertexbuffer.h | 1 - .../webgpu/kinc/backend/graphics5/WebGPU.c | 6 - .../kinc/backend/graphics5/commandlist.c | 13 +- .../webgpu/kinc/backend/graphics5/pipeline.c | 8 +- .../kinc/backend/graphics5/vertexbuffer.c | 2 +- armorcore/sources/iron.h | 53 +--- armorcore/sources/iron_ui_nodes.c | 7 +- armorcore/sources/kinc/graphics2/g2.c | 36 +-- armorcore/sources/kinc/graphics4/graphics.h | 2 - armorcore/sources/kinc/graphics4/pipeline.c.h | 5 +- armorcore/sources/kinc/graphics4/pipeline.h | 2 +- .../sources/kinc/graphics4/vertexbuffer.c.h | 6 - .../sources/kinc/graphics4/vertexbuffer.h | 4 +- .../sources/kinc/graphics4/vertexstructure.h | 1 - .../sources/kinc/graphics5/commandlist.h | 4 +- armorcore/sources/kinc/graphics5/pipeline.c.h | 5 +- armorcore/sources/kinc/graphics5/pipeline.h | 2 +- .../sources/kinc/graphics5/vertexbuffer.h | 3 +- armorcore/sources/ts/g4.ts | 23 +- armorcore/sources/ts/iron.ts | 4 +- armorcore/sources/ts/mesh_data.ts | 29 -- armorcore/sources/ts/mesh_object.ts | 23 +- armorcore/sources/ts/particle_sys.ts | 6 +- armorcore/sources/ts/scene.ts | 10 - armorcore/sources/ts/shader_data.ts | 44 +-- armorcore/tools/io_export_arm.py | 1 - armorforge/assets/meshes/box.arm | Bin 1402 -> 1386 bytes armorforge/assets/meshes/box_bevel.arm | Bin 19834 -> 19818 bytes armorforge/assets/meshes/cone.arm | Bin 6485 -> 6469 bytes armorforge/assets/meshes/cylinder.arm | Bin 10057 -> 10041 bytes armorforge/assets/meshes/sphere.arm | Bin 177523 -> 177507 bytes armorforge/assets/meshes/torus.arm | Bin 203632 -> 203616 bytes armorpaint/assets/meshes/cube_shared_uvs.arm | Bin 1315 -> 1299 bytes base/assets/Scene.arm | Bin 179310 -> 179086 bytes base/sources/import_envmap.ts | 2 +- base/sources/line_draw.ts | 4 +- base/sources/pipes.ts | 30 +- base/sources/ui_view2d.ts | 2 +- base/sources/util_encode.ts | 2 - base/sources/util_uv.ts | 2 +- 58 files changed, 266 insertions(+), 557 deletions(-) diff --git a/armorcore/sources/backends/direct3d12/kinc/backend/graphics5/Direct3D12.c.h b/armorcore/sources/backends/direct3d12/kinc/backend/graphics5/Direct3D12.c.h index c7225167..edbeb3dc 100644 --- a/armorcore/sources/backends/direct3d12/kinc/backend/graphics5/Direct3D12.c.h +++ b/armorcore/sources/backends/direct3d12/kinc/backend/graphics5/Direct3D12.c.h @@ -444,9 +444,6 @@ void kinc_g5_begin(kinc_g5_render_target_t *renderTarget, int windowId) { // commandList->ClearRenderTargetView(GetCPUDescriptorHandle(renderTargetDescriptorHeap), clearColor, 0, nullptr); // commandList->ClearDepthStencilView(GetCPUDescriptorHandle(depthStencilDescriptorHeap), D3D12_CLEAR_FLAG_DEPTH, 1.0f, 0, 0, nullptr); - - static int frameNumber = 0; - frameNumber++; } void kinc_g5_end(int window) { diff --git a/armorcore/sources/backends/direct3d12/kinc/backend/graphics5/commandlist.c.h b/armorcore/sources/backends/direct3d12/kinc/backend/graphics5/commandlist.c.h index ac97d082..a82faa55 100644 --- a/armorcore/sources/backends/direct3d12/kinc/backend/graphics5/commandlist.c.h +++ b/armorcore/sources/backends/direct3d12/kinc/backend/graphics5/commandlist.c.h @@ -180,16 +180,6 @@ void kinc_g5_command_list_draw_indexed_vertices_from_to(struct kinc_g5_command_l list->impl._commandList->DrawIndexedInstanced(count, 1, start, 0, 0); } -void kinc_g5_command_list_draw_indexed_vertices_instanced(kinc_g5_command_list_t *list, int instanceCount) { - kinc_g5_command_list_draw_indexed_vertices_instanced_from_to(list, instanceCount, 0, list->impl._indexCount); -} -void kinc_g5_command_list_draw_indexed_vertices_instanced_from_to(kinc_g5_command_list_t *list, int instanceCount, int start, int count) { - assert(list->impl.open); - - list->impl._commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - list->impl._commandList->DrawIndexedInstanced(count, instanceCount, start, 0, 0); -} - void kinc_g5_command_list_execute(kinc_g5_command_list_t *list) { assert(!list->impl.open); @@ -261,16 +251,16 @@ void kinc_g5_command_list_set_pipeline(struct kinc_g5_command_list *list, kinc_g kinc_g5_internal_setConstants(list, list->impl._currentPipeline); } -void kinc_g5_command_list_set_vertex_buffers(struct kinc_g5_command_list *list, kinc_g5_vertex_buffer_t **buffers, int *offsets, int count) { +void kinc_g5_command_list_set_vertex_buffer(struct kinc_g5_command_list *list, kinc_g5_vertex_buffer_t *buffer) { assert(list->impl.open); - D3D12_VERTEX_BUFFER_VIEW *views = (D3D12_VERTEX_BUFFER_VIEW *)alloca(sizeof(D3D12_VERTEX_BUFFER_VIEW) * count); - ZeroMemory(views, sizeof(D3D12_VERTEX_BUFFER_VIEW) * count); - for (int i = 0; i < count; ++i) { - views[i].BufferLocation = buffers[i]->impl.uploadBuffer->GetGPUVirtualAddress() + offsets[i] * kinc_g5_vertex_buffer_stride(buffers[i]); - views[i].SizeInBytes = (kinc_g5_vertex_buffer_count(buffers[i]) - offsets[i]) * kinc_g5_vertex_buffer_stride(buffers[i]); - views[i].StrideInBytes = kinc_g5_vertex_buffer_stride(buffers[i]); // * kinc_g5_vertex_buffer_count(buffers[i]); - } + D3D12_VERTEX_BUFFER_VIEW *views = (D3D12_VERTEX_BUFFER_VIEW *)alloca(sizeof(D3D12_VERTEX_BUFFER_VIEW) * 1); + ZeroMemory(views, sizeof(D3D12_VERTEX_BUFFER_VIEW) * 1); + + views[0].BufferLocation = buffer->impl.uploadBuffer->GetGPUVirtualAddress(); + views[0].SizeInBytes = (kinc_g5_vertex_buffer_count(buffer)) * kinc_g5_vertex_buffer_stride(buffer); + views[0].StrideInBytes = kinc_g5_vertex_buffer_stride(buffer); + list->impl._commandList->IASetVertexBuffers(0, count, views); } diff --git a/armorcore/sources/backends/direct3d12/kinc/backend/graphics5/pipeline.c.h b/armorcore/sources/backends/direct3d12/kinc/backend/graphics5/pipeline.c.h index d7c82cd7..52e7e014 100644 --- a/armorcore/sources/backends/direct3d12/kinc/backend/graphics5/pipeline.c.h +++ b/armorcore/sources/backends/direct3d12/kinc/backend/graphics5/pipeline.c.h @@ -241,12 +241,8 @@ static void set_blend_state(D3D12_BLEND_DESC *blend_desc, kinc_g5_pipeline_t *pi void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipe) { // TODO FLOAT4x4 int vertexAttributeCount = 0; - for (int i = 0; i < 16; ++i) { - if (pipe->inputLayout[i] == NULL) { - break; - } - vertexAttributeCount += pipe->inputLayout[i]->size; - } + vertexAttributeCount += pipe->inputLayout->size; + D3D12_INPUT_ELEMENT_DESC *vertexDesc = (D3D12_INPUT_ELEMENT_DESC *)alloca(sizeof(D3D12_INPUT_ELEMENT_DESC) * vertexAttributeCount); ZeroMemory(vertexDesc, sizeof(D3D12_INPUT_ELEMENT_DESC) * vertexAttributeCount); int curAttr = 0; @@ -256,9 +252,8 @@ void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipe) { vertexDesc[curAttr].SemanticIndex = findAttribute(pipe->vertexShader, pipe->inputLayout[stream]->elements[i].name).attribute; vertexDesc[curAttr].InputSlot = stream; vertexDesc[curAttr].AlignedByteOffset = (i == 0) ? 0 : D3D12_APPEND_ALIGNED_ELEMENT; - vertexDesc[curAttr].InputSlotClass = - pipe->inputLayout[stream]->instanced ? D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA : D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA; - vertexDesc[curAttr].InstanceDataStepRate = pipe->inputLayout[stream]->instanced ? 1 : 0; + vertexDesc[curAttr].InputSlotClass = D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA; + vertexDesc[curAttr].InstanceDataStepRate = 0; switch (pipe->inputLayout[stream]->elements[i].data) { case KINC_G4_VERTEX_DATA_F32_1X: diff --git a/armorcore/sources/backends/direct3d12/kinc/backend/graphics5/vertexbuffer.c.h b/armorcore/sources/backends/direct3d12/kinc/backend/graphics5/vertexbuffer.c.h index 14f9bcda..495f9df5 100644 --- a/armorcore/sources/backends/direct3d12/kinc/backend/graphics5/vertexbuffer.c.h +++ b/armorcore/sources/backends/direct3d12/kinc/backend/graphics5/vertexbuffer.c.h @@ -7,7 +7,7 @@ kinc_g5_vertex_buffer_t *_current_vertex_buffer = NULL; -void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int count, kinc_g5_vertex_structure_t *structure, bool gpuMemory, int instanceDataStepRate) { +void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int count, kinc_g5_vertex_structure_t *structure, bool gpuMemory) { buffer->impl.myCount = count; buffer->impl.myStride = 0; diff --git a/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/G4.c.h b/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/G4.c.h index e440b9ab..bd957777 100644 --- a/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/G4.c.h +++ b/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/G4.c.h @@ -28,7 +28,6 @@ kinc_g5_command_list_t commandList; -uint64_t frameNumber = 0; bool waitAfterNextDraw = false; static kinc_g5_constant_buffer_t vertexConstantBuffer; @@ -65,7 +64,6 @@ static struct { static int current_window; -#define MAX_VERTEX_BUFFERS 16 #define MAX_TEXTURES 16 typedef struct render_state { @@ -73,10 +71,7 @@ typedef struct render_state { kinc_g5_compute_shader *compute_shader; kinc_g5_index_buffer_t *index_buffer; - - kinc_g5_vertex_buffer_t *vertex_buffers[MAX_VERTEX_BUFFERS]; - int vertex_buffer_offsets[MAX_VERTEX_BUFFERS]; - int vertex_buffer_count; + kinc_g5_vertex_buffer_t *vertex_buffer; bool viewport_set; int viewport_x; @@ -207,9 +202,8 @@ static void endDraw(bool compute) { if (current_state.index_buffer != NULL) { kinc_g5_command_list_set_index_buffer(&commandList, current_state.index_buffer); } - if (current_state.vertex_buffer_count > 0) { - kinc_g5_command_list_set_vertex_buffers(&commandList, current_state.vertex_buffers, current_state.vertex_buffer_offsets, - current_state.vertex_buffer_count); + if (current_state.vertex_buffer != NULL) { + kinc_g5_command_list_set_vertex_buffer(&commandList, current_state.vertex_buffer); } if (current_state.viewport_set) { kinc_g5_command_list_viewport(&commandList, current_state.viewport_x, current_state.viewport_y, current_state.viewport_width, @@ -259,18 +253,6 @@ void kinc_g4_draw_indexed_vertices_from_to(int start, int count) { endDraw(false); } -void kinc_g4_draw_indexed_vertices_instanced(int instanceCount) { - startDraw(false); - kinc_g5_command_list_draw_indexed_vertices_instanced(&commandList, instanceCount); - endDraw(false); -} - -void kinc_g4_draw_indexed_vertices_instanced_from_to(int instanceCount, int start, int count) { - startDraw(false); - kinc_g5_command_list_draw_indexed_vertices_instanced_from_to(&commandList, instanceCount, start, count); - endDraw(false); -} - void kinc_g4_clear(unsigned flags, unsigned color, float depth) { if (windows[current_window].current_render_target_count > 0) { if (windows[current_window].current_render_targets[0] == NULL) { @@ -321,11 +303,7 @@ void kinc_g4_begin(int window) { current_state.pipeline = NULL; current_state.compute_shader = NULL; current_state.index_buffer = NULL; - for (int i = 0; i < MAX_VERTEX_BUFFERS; ++i) { - current_state.vertex_buffers[i] = NULL; - current_state.vertex_buffer_offsets[i] = 0; - } - current_state.vertex_buffer_count = 0; + current_state.vertex_buffer = NULL; current_state.viewport_set = false; current_state.scissor_set = false; current_state.texture_count = 0; @@ -345,8 +323,6 @@ void kinc_g4_begin(int window) { kinc_g5_command_list_framebuffer_to_render_target_barrier(&commandList, &windows[current_window].framebuffers[windows[current_window].currentBuffer]); kinc_g4_restore_render_target(); - - ++frameNumber; } void kinc_g4_viewport(int x, int y, int width, int height) { @@ -576,22 +552,10 @@ void kinc_g4_set_render_targets(kinc_g4_render_target_t **targets, int count) { current_state.scissor_set = false; } -void kinc_g4_set_vertex_buffers(kinc_g4_vertex_buffer_t **buffers, int count) { - assert(count <= MAX_VERTEX_BUFFERS); - for (int i = 0; i < count; ++i) { - current_state.vertex_buffers[i] = &buffers[i]->impl._buffer; - int index = buffers[i]->impl._currentIndex; - current_state.vertex_buffer_offsets[i] = index * kinc_g4_vertex_buffer_count(buffers[i]); - } - current_state.vertex_buffer_count = count; - kinc_g5_command_list_set_vertex_buffers(&commandList, current_state.vertex_buffers, current_state.vertex_buffer_offsets, count); -} - -int kinc_internal_g4_vertex_buffer_set(kinc_g4_vertex_buffer_t *buffer, int offset) { - kinc_g4_vertex_buffer_t *buffers[1]; - buffers[0] = buffer; - kinc_g4_set_vertex_buffers(buffers, 1); - return 0; +void kinc_g4_set_vertex_buffer(kinc_g4_vertex_buffer_t *buffer) { + kinc_g5_vertex_buffer_t *g5_vertex_buffer = &buffer->impl._buffer; + current_state.vertex_buffer = g5_vertex_buffer; + kinc_g5_command_list_set_vertex_buffer(&commandList, g5_vertex_buffer); } void kinc_g4_set_index_buffer(kinc_g4_index_buffer_t *buffer) { diff --git a/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/pipeline.c.h b/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/pipeline.c.h index 19c356cc..31077bbd 100644 --- a/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/pipeline.c.h +++ b/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/pipeline.c.h @@ -30,9 +30,7 @@ kinc_g4_texture_unit_t kinc_g4_pipeline_get_texture_unit(kinc_g4_pipeline_t *pip } void kinc_g4_pipeline_compile(kinc_g4_pipeline_t *pipe) { - for (int i = 0; i < 16; ++i) { - pipe->impl._pipeline.inputLayout[i] = pipe->input_layout[i]; - } + pipe->impl._pipeline.inputLayout = pipe->input_layout; pipe->impl._pipeline.vertexShader = &pipe->vertex_shader->impl._shader; pipe->impl._pipeline.fragmentShader = &pipe->fragment_shader->impl._shader; pipe->impl._pipeline.blend_source = (kinc_g5_blending_factor_t)pipe->blend_source; diff --git a/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/vertexbuffer.c.h b/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/vertexbuffer.c.h index 0299b9f4..0d4dcbcf 100644 --- a/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/vertexbuffer.c.h +++ b/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/vertexbuffer.c.h @@ -3,15 +3,12 @@ #include #include -extern uint64_t frameNumber; extern bool waitAfterNextDraw; -void kinc_g4_vertex_buffer_init(kinc_g4_vertex_buffer_t *buffer, int count, kinc_g4_vertex_structure_t *structure, kinc_g4_usage_t usage, - int instanceDataStepRate) { - int multiple = usage == KINC_G4_USAGE_STATIC ? 1 : 500; - kinc_g5_vertex_buffer_init(&buffer->impl._buffer, count * multiple, structure, usage == KINC_G4_USAGE_STATIC, instanceDataStepRate); +void kinc_g4_vertex_buffer_init(kinc_g4_vertex_buffer_t *buffer, int count, kinc_g4_vertex_structure_t *structure, kinc_g4_usage_t usage) { + int multiple = usage == KINC_G4_USAGE_STATIC ? 1 : 2; + kinc_g5_vertex_buffer_init(&buffer->impl._buffer, count * multiple, structure, usage == KINC_G4_USAGE_STATIC); buffer->impl._multiple = multiple; - buffer->impl._lastFrameNumber = 0; buffer->impl._currentIndex = 0; buffer->impl.myCount = count; } @@ -21,13 +18,13 @@ void kinc_g4_vertex_buffer_destroy(kinc_g4_vertex_buffer_t *buffer) { } static void prepareLock(kinc_g4_vertex_buffer_t *buffer) { - ++buffer->impl._currentIndex; - if (buffer->impl._currentIndex >= buffer->impl._multiple - 1) { + // ++buffer->impl._currentIndex; + // if (buffer->impl._currentIndex >= buffer->impl._multiple - 1) { waitAfterNextDraw = true; - } - if (buffer->impl._currentIndex >= buffer->impl._multiple) { - buffer->impl._currentIndex = 0; - } + // } + // if (buffer->impl._currentIndex >= buffer->impl._multiple) { + // buffer->impl._currentIndex = 0; + // } } float *kinc_g4_vertex_buffer_lock_all(kinc_g4_vertex_buffer_t *buffer) { diff --git a/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/vertexbuffer.h b/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/vertexbuffer.h index 90b109f7..4a303494 100644 --- a/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/vertexbuffer.h +++ b/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/vertexbuffer.h @@ -7,5 +7,4 @@ typedef struct { kinc_g5_vertex_buffer_t _buffer; int _currentIndex; int _multiple; - uint64_t _lastFrameNumber; } kinc_g4_vertex_buffer_impl_t; diff --git a/armorcore/sources/backends/metal/kinc/backend/graphics5/Metal.m.h b/armorcore/sources/backends/metal/kinc/backend/graphics5/Metal.m.h index d9c76747..cce4151e 100644 --- a/armorcore/sources/backends/metal/kinc/backend/graphics5/Metal.m.h +++ b/armorcore/sources/backends/metal/kinc/backend/graphics5/Metal.m.h @@ -48,10 +48,6 @@ void kinc_g5_internal_init_window(int window, int depthBufferBits, bool vsync) { void kinc_g5_flush(void) {} -void kinc_g5_draw_indexed_vertices_instanced(int instanceCount) {} - -void kinc_g5_draw_indexed_vertices_instanced_from_to(int instanceCount, int start, int count) {} - bool kinc_internal_metal_has_depth = false; bool kinc_internal_current_render_target_has_depth(void) { diff --git a/armorcore/sources/backends/metal/kinc/backend/graphics5/commandlist.m.h b/armorcore/sources/backends/metal/kinc/backend/graphics5/commandlist.m.h index b828195d..2bc78a7b 100644 --- a/armorcore/sources/backends/metal/kinc/backend/graphics5/commandlist.m.h +++ b/armorcore/sources/backends/metal/kinc/backend/graphics5/commandlist.m.h @@ -79,22 +79,6 @@ void kinc_g5_command_list_draw_indexed_vertices_from_to(kinc_g5_command_list_t * indexBufferOffset:start * 4]; } -void kinc_g5_command_list_draw_indexed_vertices_instanced(kinc_g5_command_list_t *list, int instanceCount) { - kinc_g5_command_list_draw_indexed_vertices_instanced_from_to(list, instanceCount, 0, kinc_g5_index_buffer_count(list->impl.current_index_buffer)); -} - -void kinc_g5_command_list_draw_indexed_vertices_instanced_from_to(kinc_g5_command_list_t *list, int instanceCount, int start, int count) { - id indexBuffer = (__bridge id)list->impl.current_index_buffer->impl.metal_buffer; - id encoder = getMetalEncoder(); - [encoder drawIndexedPrimitives:MTLPrimitiveTypeTriangle - indexCount:count - indexType:(list->impl.current_index_buffer->impl.format == KINC_G5_INDEX_BUFFER_FORMAT_16BIT ? MTLIndexTypeUInt16 : MTLIndexTypeUInt32) - indexBuffer:indexBuffer - indexBufferOffset:start * 4 - instanceCount:instanceCount - baseVertex:0 - baseInstance:0]; -} void kinc_g5_command_list_viewport(kinc_g5_command_list_t *list, int x, int y, int width, int height) { id encoder = getMetalEncoder(); MTLViewport viewport; @@ -148,8 +132,8 @@ void kinc_g5_command_list_set_pipeline(kinc_g5_command_list_t *list, struct kinc lastPipeline = pipeline; } -void kinc_g5_command_list_set_vertex_buffers(kinc_g5_command_list_t *list, struct kinc_g5_vertex_buffer **buffers, int *offsets, int count) { - kinc_g5_internal_vertex_buffer_set(buffers[0], offsets[0]); +void kinc_g5_command_list_set_vertex_buffer(kinc_g5_command_list_t *list, struct kinc_g5_vertex_buffer *buffer) { + kinc_g5_internal_vertex_buffer_set(buffer); } void kinc_g5_command_list_set_index_buffer(kinc_g5_command_list_t *list, struct kinc_g5_index_buffer *buffer) { diff --git a/armorcore/sources/backends/metal/kinc/backend/graphics5/pipeline.m.h b/armorcore/sources/backends/metal/kinc/backend/graphics5/pipeline.m.h index 13a932c1..a1d25e79 100644 --- a/armorcore/sources/backends/metal/kinc/backend/graphics5/pipeline.m.h +++ b/armorcore/sources/backends/metal/kinc/backend/graphics5/pipeline.m.h @@ -168,11 +168,11 @@ void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipeline) { float offset = 0; MTLVertexDescriptor *vertexDescriptor = [[MTLVertexDescriptor alloc] init]; - for (int i = 0; i < pipeline->inputLayout[0]->size; ++i) { - int index = findAttributeIndex(renderPipelineDesc.vertexFunction.vertexAttributes, pipeline->inputLayout[0]->elements[i].name); + for (int i = 0; i < pipeline->inputLayout->size; ++i) { + int index = findAttributeIndex(renderPipelineDesc.vertexFunction.vertexAttributes, pipeline->inputLayout->elements[i].name); if (index < 0) { - kinc_log(KINC_LOG_LEVEL_WARNING, "Could not find vertex attribute %s\n", pipeline->inputLayout[0]->elements[i].name); + kinc_log(KINC_LOG_LEVEL_WARNING, "Could not find vertex attribute %s\n", pipeline->inputLayout->elements[i].name); } if (index >= 0) { @@ -180,9 +180,9 @@ void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipeline) { vertexDescriptor.attributes[index].offset = offset; } - offset += kinc_g4_vertex_data_size(pipeline->inputLayout[0]->elements[i].data); + offset += kinc_g4_vertex_data_size(pipeline->inputLayout->elements[i].data); if (index >= 0) { - switch (pipeline->inputLayout[0]->elements[i].data) { + switch (pipeline->inputLayout->elements[i].data) { case KINC_G4_VERTEX_DATA_NONE: assert(false); break; @@ -372,7 +372,7 @@ kinc_g5_constant_location_t kinc_g5_pipeline_get_constant_location(kinc_g5_pipel location.impl.vertexOffset = -1; location.impl.fragmentOffset = -1; location.impl.computeOffset = -1; - + MTLRenderPipelineReflection *reflection = (__bridge MTLRenderPipelineReflection *)pipeline->impl._reflection; for (MTLArgument *arg in reflection.vertexArguments) { diff --git a/armorcore/sources/backends/metal/kinc/backend/graphics5/vertexbuffer.m.h b/armorcore/sources/backends/metal/kinc/backend/graphics5/vertexbuffer.m.h index acd5bb65..349bcbe9 100644 --- a/armorcore/sources/backends/metal/kinc/backend/graphics5/vertexbuffer.m.h +++ b/armorcore/sources/backends/metal/kinc/backend/graphics5/vertexbuffer.m.h @@ -17,7 +17,7 @@ static void vertex_buffer_unset(kinc_g5_vertex_buffer_t *buffer) { currentVertexBuffer = NULL; } -void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int count, kinc_g5_vertex_structure_t *structure, bool gpuMemory, int instanceDataStepRate) { +void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int count, kinc_g5_vertex_structure_t *structure, bool gpuMemory) { memset(&buffer->impl, 0, sizeof(buffer->impl)); buffer->impl.myCount = count; buffer->impl.gpuMemory = gpuMemory; diff --git a/armorcore/sources/backends/vulkan/kinc/backend/graphics5/ShaderHash.c.h b/armorcore/sources/backends/vulkan/kinc/backend/graphics5/ShaderHash.c.h index c1114a18..bfbd458d 100644 --- a/armorcore/sources/backends/vulkan/kinc/backend/graphics5/ShaderHash.c.h +++ b/armorcore/sources/backends/vulkan/kinc/backend/graphics5/ShaderHash.c.h @@ -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; diff --git a/armorcore/sources/backends/vulkan/kinc/backend/graphics5/commandlist.c.h b/armorcore/sources/backends/vulkan/kinc/backend/graphics5/commandlist.c.h index ef82171b..e93105c1 100644 --- a/armorcore/sources/backends/vulkan/kinc/backend/graphics5/commandlist.c.h +++ b/armorcore/sources/backends/vulkan/kinc/backend/graphics5/commandlist.c.h @@ -393,14 +393,6 @@ void kinc_g5_command_list_draw_indexed_vertices_from_to(kinc_g5_command_list_t * vkCmdDrawIndexed(list->impl._buffer, count, 1, start, 0, 0); } -void kinc_g5_command_list_draw_indexed_vertices_instanced(kinc_g5_command_list_t *list, int instanceCount) { - kinc_g5_command_list_draw_indexed_vertices_instanced_from_to(list, instanceCount, 0, list->impl._indexCount); -} - -void kinc_g5_command_list_draw_indexed_vertices_instanced_from_to(kinc_g5_command_list_t *list, int instanceCount, int start, int count) { - vkCmdDrawIndexed(list->impl._buffer, count, instanceCount, start, 0, 0); -} - void kinc_g5_command_list_viewport(kinc_g5_command_list_t *list, int x, int y, int width, int height) { VkViewport viewport; memset(&viewport, 0, sizeof(viewport)); @@ -452,16 +444,12 @@ void kinc_g5_command_list_set_pipeline(kinc_g5_command_list_t *list, struct kinc } } -void kinc_g5_command_list_set_vertex_buffers(kinc_g5_command_list_t *list, struct kinc_g5_vertex_buffer **vertexBuffers, int *offsets_, int count) { -// this seems to be a no-op function? -// kinc_g5_internal_vertex_buffer_set(vertexBuffers[0], 0); - VkBuffer buffers[count]; - VkDeviceSize offsets[count]; - for (int i = 0; i < count; ++i) { - buffers[i] = vertexBuffers[i]->impl.vertices.buf; - offsets[i] = (VkDeviceSize)(offsets_[i] * kinc_g5_vertex_buffer_stride(vertexBuffers[i])); - } - vkCmdBindVertexBuffers(list->impl._buffer, 0, count, buffers, offsets); +void kinc_g5_command_list_set_vertex_buffer(kinc_g5_command_list_t *list, struct kinc_g5_vertex_buffer *vertexBuffer) { + VkBuffer buffers[1]; + VkDeviceSize offsets[1]; + buffers[0] = vertexBuffer->impl.vertices.buf; + offsets[0] = (VkDeviceSize)(0); + vkCmdBindVertexBuffers(list->impl._buffer, 0, 1, buffers, offsets); } void kinc_g5_command_list_set_index_buffer(kinc_g5_command_list_t *list, struct kinc_g5_index_buffer *indexBuffer) { diff --git a/armorcore/sources/backends/vulkan/kinc/backend/graphics5/indexbuffer.c.h b/armorcore/sources/backends/vulkan/kinc/backend/graphics5/indexbuffer.c.h index b296b723..b7cd950e 100644 --- a/armorcore/sources/backends/vulkan/kinc/backend/graphics5/indexbuffer.c.h +++ b/armorcore/sources/backends/vulkan/kinc/backend/graphics5/indexbuffer.c.h @@ -4,12 +4,7 @@ bool memory_type_from_properties(uint32_t typeBits, VkFlags requirements_mask, uint32_t *typeIndex); -kinc_g5_index_buffer_t *currentIndexBuffer = NULL; - static void unset(kinc_g5_index_buffer_t *buffer) { - if (currentIndexBuffer == buffer) { - currentIndexBuffer = NULL; - } } void kinc_g5_index_buffer_init(kinc_g5_index_buffer_t *buffer, int indexCount, kinc_g5_index_buffer_format_t format, bool gpuMemory) { diff --git a/armorcore/sources/backends/vulkan/kinc/backend/graphics5/pipeline.c.h b/armorcore/sources/backends/vulkan/kinc/backend/graphics5/pipeline.c.h index 2a257131..7532f5fa 100644 --- a/armorcore/sources/backends/vulkan/kinc/backend/graphics5/pipeline.c.h +++ b/armorcore/sources/backends/vulkan/kinc/backend/graphics5/pipeline.c.h @@ -419,8 +419,7 @@ void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipeline) { VkPipelineDepthStencilStateCreateInfo ds = {0}; VkPipelineViewportStateCreateInfo vp = {0}; VkPipelineMultisampleStateCreateInfo ms = {0}; -#define dynamicStatesCount 2 - VkDynamicState dynamicStateEnables[dynamicStatesCount]; + VkDynamicState dynamicStateEnables[2]; VkPipelineDynamicStateCreateInfo dynamicState = {0}; memset(dynamicStateEnables, 0, sizeof(dynamicStateEnables)); @@ -432,160 +431,147 @@ void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipeline) { pipeline_info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; pipeline_info.layout = pipeline->impl.pipeline_layout; - int vertexAttributeCount = 0; - int vertexBindingCount = 0; - for (int i = 0; i < 16; ++i) { - if (pipeline->inputLayout[i] == NULL) { - break; - } - vertexAttributeCount += pipeline->inputLayout[i]->size; - vertexBindingCount++; - } - - VkVertexInputBindingDescription vi_bindings[vertexBindingCount]; + VkVertexInputBindingDescription vi_bindings[1]; + int vertexAttributeCount = pipeline->inputLayout->size; VkVertexInputAttributeDescription vi_attrs[vertexAttributeCount]; VkPipelineVertexInputStateCreateInfo vi = {0}; memset(&vi, 0, sizeof(vi)); vi.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; vi.pNext = NULL; - vi.vertexBindingDescriptionCount = vertexBindingCount; + vi.vertexBindingDescriptionCount = 1; vi.pVertexBindingDescriptions = vi_bindings; vi.vertexAttributeDescriptionCount = vertexAttributeCount; vi.pVertexAttributeDescriptions = vi_attrs; uint32_t attr = 0; - for (int binding = 0; binding < vertexBindingCount; ++binding) { - uint32_t offset = 0; - uint32_t stride = 0; - for (int i = 0; i < pipeline->inputLayout[binding]->size; ++i) { - kinc_g5_vertex_element_t element = pipeline->inputLayout[binding]->elements[i]; + uint32_t offset = 0; + for (int i = 0; i < pipeline->inputLayout->size; ++i) { + kinc_g5_vertex_element_t element = pipeline->inputLayout->elements[i]; - vi_attrs[attr].binding = binding; - vi_attrs[attr].location = find_number(pipeline->impl.vertexLocations, element.name); - vi_attrs[attr].offset = offset; - offset += kinc_g4_vertex_data_size(element.data); - stride += kinc_g4_vertex_data_size(element.data); + vi_attrs[attr].binding = 0; + vi_attrs[attr].location = find_number(pipeline->impl.vertexLocations, element.name); + vi_attrs[attr].offset = offset; + offset += kinc_g4_vertex_data_size(element.data); - switch (element.data) { - case KINC_G4_VERTEX_DATA_F32_1X: - vi_attrs[attr].format = VK_FORMAT_R32_SFLOAT; - break; - case KINC_G4_VERTEX_DATA_F32_2X: - vi_attrs[attr].format = VK_FORMAT_R32G32_SFLOAT; - break; - case KINC_G4_VERTEX_DATA_F32_3X: - vi_attrs[attr].format = VK_FORMAT_R32G32B32_SFLOAT; - break; - case KINC_G4_VERTEX_DATA_F32_4X: - vi_attrs[attr].format = VK_FORMAT_R32G32B32A32_SFLOAT; - break; - case KINC_G4_VERTEX_DATA_I8_1X: - vi_attrs[attr].format = VK_FORMAT_R8_SINT; - break; - case KINC_G4_VERTEX_DATA_U8_1X: - vi_attrs[attr].format = VK_FORMAT_R8_UINT; - break; - case KINC_G4_VERTEX_DATA_I8_1X_NORMALIZED: - vi_attrs[attr].format = VK_FORMAT_R8_SNORM; - break; - case KINC_G4_VERTEX_DATA_U8_1X_NORMALIZED: - vi_attrs[attr].format = VK_FORMAT_R8_UNORM; - break; - case KINC_G4_VERTEX_DATA_I8_2X: - vi_attrs[attr].format = VK_FORMAT_R8G8_SINT; - break; - case KINC_G4_VERTEX_DATA_U8_2X: - vi_attrs[attr].format = VK_FORMAT_R8G8_UINT; - break; - case KINC_G4_VERTEX_DATA_I8_2X_NORMALIZED: - vi_attrs[attr].format = VK_FORMAT_R8G8_SNORM; - break; - case KINC_G4_VERTEX_DATA_U8_2X_NORMALIZED: - vi_attrs[attr].format = VK_FORMAT_R8G8_UNORM; - break; - case KINC_G4_VERTEX_DATA_I8_4X: - vi_attrs[attr].format = VK_FORMAT_R8G8B8A8_SINT; - break; - case KINC_G4_VERTEX_DATA_U8_4X: - vi_attrs[attr].format = VK_FORMAT_R8G8B8A8_UINT; - break; - case KINC_G4_VERTEX_DATA_I8_4X_NORMALIZED: - vi_attrs[attr].format = VK_FORMAT_R8G8B8A8_SNORM; - break; - case KINC_G4_VERTEX_DATA_U8_4X_NORMALIZED: - vi_attrs[attr].format = VK_FORMAT_R8G8B8A8_UNORM; - break; - case KINC_G4_VERTEX_DATA_I16_1X: - vi_attrs[attr].format = VK_FORMAT_R16_SINT; - break; - case KINC_G4_VERTEX_DATA_U16_1X: - vi_attrs[attr].format = VK_FORMAT_R16_UINT; - break; - case KINC_G4_VERTEX_DATA_I16_1X_NORMALIZED: - vi_attrs[attr].format = VK_FORMAT_R16_SNORM; - break; - case KINC_G4_VERTEX_DATA_U16_1X_NORMALIZED: - vi_attrs[attr].format = VK_FORMAT_R16_UNORM; - break; - case KINC_G4_VERTEX_DATA_I16_2X: - vi_attrs[attr].format = VK_FORMAT_R16G16_SINT; - break; - case KINC_G4_VERTEX_DATA_U16_2X: - vi_attrs[attr].format = VK_FORMAT_R16G16_UINT; - break; - case KINC_G4_VERTEX_DATA_I16_2X_NORMALIZED: - vi_attrs[attr].format = VK_FORMAT_R16G16_SNORM; - break; - case KINC_G4_VERTEX_DATA_U16_2X_NORMALIZED: - vi_attrs[attr].format = VK_FORMAT_R16G16_UNORM; - break; - case KINC_G4_VERTEX_DATA_I16_4X: - vi_attrs[attr].format = VK_FORMAT_R16G16B16A16_SINT; - break; - case KINC_G4_VERTEX_DATA_U16_4X: - vi_attrs[attr].format = VK_FORMAT_R16G16B16A16_UINT; - break; - case KINC_G4_VERTEX_DATA_I16_4X_NORMALIZED: - vi_attrs[attr].format = VK_FORMAT_R16G16B16A16_SNORM; - break; - case KINC_G4_VERTEX_DATA_U16_4X_NORMALIZED: - vi_attrs[attr].format = VK_FORMAT_R16G16B16A16_UNORM; - break; - case KINC_G4_VERTEX_DATA_I32_1X: - vi_attrs[attr].format = VK_FORMAT_R32_SINT; - break; - case KINC_G4_VERTEX_DATA_U32_1X: - vi_attrs[attr].format = VK_FORMAT_R32_UINT; - break; - case KINC_G4_VERTEX_DATA_I32_2X: - vi_attrs[attr].format = VK_FORMAT_R32G32_SINT; - break; - case KINC_G4_VERTEX_DATA_U32_2X: - vi_attrs[attr].format = VK_FORMAT_R32G32_UINT; - break; - case KINC_G4_VERTEX_DATA_I32_3X: - vi_attrs[attr].format = VK_FORMAT_R32G32B32_SINT; - break; - case KINC_G4_VERTEX_DATA_U32_3X: - vi_attrs[attr].format = VK_FORMAT_R32G32B32_UINT; - break; - case KINC_G4_VERTEX_DATA_I32_4X: - vi_attrs[attr].format = VK_FORMAT_R32G32B32A32_SINT; - break; - case KINC_G4_VERTEX_DATA_U32_4X: - vi_attrs[attr].format = VK_FORMAT_R32G32B32A32_UINT; - break; - default: - assert(false); - break; - } - attr++; + switch (element.data) { + case KINC_G4_VERTEX_DATA_F32_1X: + vi_attrs[attr].format = VK_FORMAT_R32_SFLOAT; + break; + case KINC_G4_VERTEX_DATA_F32_2X: + vi_attrs[attr].format = VK_FORMAT_R32G32_SFLOAT; + break; + case KINC_G4_VERTEX_DATA_F32_3X: + vi_attrs[attr].format = VK_FORMAT_R32G32B32_SFLOAT; + break; + case KINC_G4_VERTEX_DATA_F32_4X: + vi_attrs[attr].format = VK_FORMAT_R32G32B32A32_SFLOAT; + break; + case KINC_G4_VERTEX_DATA_I8_1X: + vi_attrs[attr].format = VK_FORMAT_R8_SINT; + break; + case KINC_G4_VERTEX_DATA_U8_1X: + vi_attrs[attr].format = VK_FORMAT_R8_UINT; + break; + case KINC_G4_VERTEX_DATA_I8_1X_NORMALIZED: + vi_attrs[attr].format = VK_FORMAT_R8_SNORM; + break; + case KINC_G4_VERTEX_DATA_U8_1X_NORMALIZED: + vi_attrs[attr].format = VK_FORMAT_R8_UNORM; + break; + case KINC_G4_VERTEX_DATA_I8_2X: + vi_attrs[attr].format = VK_FORMAT_R8G8_SINT; + break; + case KINC_G4_VERTEX_DATA_U8_2X: + vi_attrs[attr].format = VK_FORMAT_R8G8_UINT; + break; + case KINC_G4_VERTEX_DATA_I8_2X_NORMALIZED: + vi_attrs[attr].format = VK_FORMAT_R8G8_SNORM; + break; + case KINC_G4_VERTEX_DATA_U8_2X_NORMALIZED: + vi_attrs[attr].format = VK_FORMAT_R8G8_UNORM; + break; + case KINC_G4_VERTEX_DATA_I8_4X: + vi_attrs[attr].format = VK_FORMAT_R8G8B8A8_SINT; + break; + case KINC_G4_VERTEX_DATA_U8_4X: + vi_attrs[attr].format = VK_FORMAT_R8G8B8A8_UINT; + break; + case KINC_G4_VERTEX_DATA_I8_4X_NORMALIZED: + vi_attrs[attr].format = VK_FORMAT_R8G8B8A8_SNORM; + break; + case KINC_G4_VERTEX_DATA_U8_4X_NORMALIZED: + vi_attrs[attr].format = VK_FORMAT_R8G8B8A8_UNORM; + break; + case KINC_G4_VERTEX_DATA_I16_1X: + vi_attrs[attr].format = VK_FORMAT_R16_SINT; + break; + case KINC_G4_VERTEX_DATA_U16_1X: + vi_attrs[attr].format = VK_FORMAT_R16_UINT; + break; + case KINC_G4_VERTEX_DATA_I16_1X_NORMALIZED: + vi_attrs[attr].format = VK_FORMAT_R16_SNORM; + break; + case KINC_G4_VERTEX_DATA_U16_1X_NORMALIZED: + vi_attrs[attr].format = VK_FORMAT_R16_UNORM; + break; + case KINC_G4_VERTEX_DATA_I16_2X: + vi_attrs[attr].format = VK_FORMAT_R16G16_SINT; + break; + case KINC_G4_VERTEX_DATA_U16_2X: + vi_attrs[attr].format = VK_FORMAT_R16G16_UINT; + break; + case KINC_G4_VERTEX_DATA_I16_2X_NORMALIZED: + vi_attrs[attr].format = VK_FORMAT_R16G16_SNORM; + break; + case KINC_G4_VERTEX_DATA_U16_2X_NORMALIZED: + vi_attrs[attr].format = VK_FORMAT_R16G16_UNORM; + break; + case KINC_G4_VERTEX_DATA_I16_4X: + vi_attrs[attr].format = VK_FORMAT_R16G16B16A16_SINT; + break; + case KINC_G4_VERTEX_DATA_U16_4X: + vi_attrs[attr].format = VK_FORMAT_R16G16B16A16_UINT; + break; + case KINC_G4_VERTEX_DATA_I16_4X_NORMALIZED: + vi_attrs[attr].format = VK_FORMAT_R16G16B16A16_SNORM; + break; + case KINC_G4_VERTEX_DATA_U16_4X_NORMALIZED: + vi_attrs[attr].format = VK_FORMAT_R16G16B16A16_UNORM; + break; + case KINC_G4_VERTEX_DATA_I32_1X: + vi_attrs[attr].format = VK_FORMAT_R32_SINT; + break; + case KINC_G4_VERTEX_DATA_U32_1X: + vi_attrs[attr].format = VK_FORMAT_R32_UINT; + break; + case KINC_G4_VERTEX_DATA_I32_2X: + vi_attrs[attr].format = VK_FORMAT_R32G32_SINT; + break; + case KINC_G4_VERTEX_DATA_U32_2X: + vi_attrs[attr].format = VK_FORMAT_R32G32_UINT; + break; + case KINC_G4_VERTEX_DATA_I32_3X: + vi_attrs[attr].format = VK_FORMAT_R32G32B32_SINT; + break; + case KINC_G4_VERTEX_DATA_U32_3X: + vi_attrs[attr].format = VK_FORMAT_R32G32B32_UINT; + break; + case KINC_G4_VERTEX_DATA_I32_4X: + vi_attrs[attr].format = VK_FORMAT_R32G32B32A32_SINT; + break; + case KINC_G4_VERTEX_DATA_U32_4X: + vi_attrs[attr].format = VK_FORMAT_R32G32B32A32_UINT; + break; + default: + assert(false); + break; } - vi_bindings[binding].binding = binding; - vi_bindings[binding].stride = stride; - vi_bindings[binding].inputRate = pipeline->inputLayout[binding]->instanced ? VK_VERTEX_INPUT_RATE_INSTANCE : VK_VERTEX_INPUT_RATE_VERTEX; + attr++; } + vi_bindings[0].binding = 0; + vi_bindings[0].stride = offset; + vi_bindings[0].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; memset(&ia, 0, sizeof(ia)); ia.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; diff --git a/armorcore/sources/backends/vulkan/kinc/backend/graphics5/raytrace.c.h b/armorcore/sources/backends/vulkan/kinc/backend/graphics5/raytrace.c.h index 3137faac..08cf98b6 100644 --- a/armorcore/sources/backends/vulkan/kinc/backend/graphics5/raytrace.c.h +++ b/armorcore/sources/backends/vulkan/kinc/backend/graphics5/raytrace.c.h @@ -470,8 +470,8 @@ void kinc_raytrace_acceleration_structure_build(kinc_raytrace_acceleration_struc if (build_bottom) { for (int i = 0; i < vb_count; ++i) { - int prim_count = ib[i]->impl.count / 3; - int vert_count = vb[i]->impl.myCount; + uint32_t prim_count = ib[i]->impl.count / 3; + uint32_t vert_count = vb[i]->impl.myCount; VkDeviceOrHostAddressConstKHR vertex_data_device_address = {0}; VkDeviceOrHostAddressConstKHR index_data_device_address = {0}; diff --git a/armorcore/sources/backends/vulkan/kinc/backend/graphics5/vertexbuffer.c.h b/armorcore/sources/backends/vulkan/kinc/backend/graphics5/vertexbuffer.c.h index 839f5e76..086c3232 100644 --- a/armorcore/sources/backends/vulkan/kinc/backend/graphics5/vertexbuffer.c.h +++ b/armorcore/sources/backends/vulkan/kinc/backend/graphics5/vertexbuffer.c.h @@ -8,13 +8,8 @@ bool memory_type_from_properties(uint32_t typeBits, VkFlags requirements_mask, uint32_t *typeIndex); -kinc_g5_vertex_buffer_t *currentVertexBuffer = NULL; -extern kinc_g5_index_buffer_t *currentIndexBuffer; - -void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int vertexCount, kinc_g5_vertex_structure_t *structure, bool gpuMemory, - int instanceDataStepRate) { +void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int vertexCount, kinc_g5_vertex_structure_t *structure, bool gpuMemory) { buffer->impl.myCount = vertexCount; - buffer->impl.instanceDataStepRate = instanceDataStepRate; buffer->impl.myStride = 0; for (int i = 0; i < structure->size; ++i) { kinc_g5_vertex_element_t element = structure->elements[i]; @@ -73,9 +68,7 @@ void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int vertexCount } static void unset_vertex_buffer(kinc_g5_vertex_buffer_t *buffer) { - if (currentVertexBuffer == buffer) { - currentVertexBuffer = NULL; - } + } void kinc_g5_vertex_buffer_destroy(kinc_g5_vertex_buffer_t *buffer) { @@ -103,13 +96,8 @@ void kinc_g5_vertex_buffer_unlock(kinc_g5_vertex_buffer_t *buffer, int count) { vkUnmapMemory(vk_ctx.device, buffer->impl.vertices.mem); } -static int setVertexAttributes(int offset) { - return 0; -} - int kinc_g5_internal_vertex_buffer_set(kinc_g5_vertex_buffer_t *buffer, int offset) { - int offsetoffset = setVertexAttributes(offset); - return offsetoffset; + return 0; } int kinc_g5_vertex_buffer_count(kinc_g5_vertex_buffer_t *buffer) { diff --git a/armorcore/sources/backends/vulkan/kinc/backend/graphics5/vertexbuffer.h b/armorcore/sources/backends/vulkan/kinc/backend/graphics5/vertexbuffer.h index db35a083..5f0cf71b 100644 --- a/armorcore/sources/backends/vulkan/kinc/backend/graphics5/vertexbuffer.h +++ b/armorcore/sources/backends/vulkan/kinc/backend/graphics5/vertexbuffer.h @@ -16,6 +16,5 @@ typedef struct { unsigned bufferId; kinc_g5_vertex_structure_t structure; VkMemoryAllocateInfo mem_alloc; - int instanceDataStepRate; struct Vertices vertices; } VertexBuffer5Impl; diff --git a/armorcore/sources/backends/webgpu/kinc/backend/graphics5/WebGPU.c b/armorcore/sources/backends/webgpu/kinc/backend/graphics5/WebGPU.c index d536e8ea..a91f638d 100644 --- a/armorcore/sources/backends/webgpu/kinc/backend/graphics5/WebGPU.c +++ b/armorcore/sources/backends/webgpu/kinc/backend/graphics5/WebGPU.c @@ -51,12 +51,6 @@ void kinc_g5_internal_init_window(int window, int depthBufferBits, bool vsync) { swapChain = wgpuDeviceCreateSwapChain(device, surface, &scDesc); } -void kinc_g5_draw_indexed_vertices_instanced(int instanceCount) {} - -void kinc_g5_draw_indexed_vertices_instanced_from_to(int instanceCount, int start, int count) {} - -void kinc_g5_draw_indexed_vertices_instanced_from_to_from(int instanceCount, int start, int count, int vertex_offset) {} - void kinc_g5_begin(kinc_g5_render_target_t *renderTarget, int window) {} void kinc_g5_end(int window) {} diff --git a/armorcore/sources/backends/webgpu/kinc/backend/graphics5/commandlist.c b/armorcore/sources/backends/webgpu/kinc/backend/graphics5/commandlist.c index 6199fa99..725a2aea 100644 --- a/armorcore/sources/backends/webgpu/kinc/backend/graphics5/commandlist.c +++ b/armorcore/sources/backends/webgpu/kinc/backend/graphics5/commandlist.c @@ -61,13 +61,6 @@ void kinc_g5_command_list_draw_indexed_vertices_from_to(kinc_g5_command_list_t * } -void kinc_g5_command_list_draw_indexed_vertices_instanced(kinc_g5_command_list_t *list, int instanceCount) { - -} -void kinc_g5_command_list_draw_indexed_vertices_instanced_from_to(kinc_g5_command_list_t *list, int instanceCount, int start, int count) { - -} - void kinc_g5_command_list_viewport(kinc_g5_command_list_t *list, int x, int y, int width, int height) { } @@ -84,9 +77,9 @@ void kinc_g5_command_list_set_pipeline(kinc_g5_command_list_t *list, struct kinc void kinc_g5_command_list_set_pipeline_layout(kinc_g5_command_list_t *list) {} -void kinc_g5_command_list_set_vertex_buffers(kinc_g5_command_list_t *list, struct kinc_g5_vertex_buffer **buffers, int *offsets, int count) { - uint64_t size = (kinc_g5_vertex_buffer_count(buffers[0]) - offsets[0]) * kinc_g5_vertex_buffer_stride(buffers[0]); - wgpuRenderPassEncoderSetVertexBuffer(list->impl.pass, 0, buffers[0]->impl.buffer, 0, size); +void kinc_g5_command_list_set_vertex_buffer(kinc_g5_command_list_t *list, struct kinc_g5_vertex_buffer *buffer) { + uint64_t size = (kinc_g5_vertex_buffer_count(buffer)) * kinc_g5_vertex_buffer_stride(buffer); + wgpuRenderPassEncoderSetVertexBuffer(list->impl.pass, 0, buffer->impl.buffer, 0, size); } void kinc_g5_command_list_set_index_buffer(kinc_g5_command_list_t *list, struct kinc_g5_index_buffer *buffer) { diff --git a/armorcore/sources/backends/webgpu/kinc/backend/graphics5/pipeline.c b/armorcore/sources/backends/webgpu/kinc/backend/graphics5/pipeline.c index 675ebd7a..051768c5 100644 --- a/armorcore/sources/backends/webgpu/kinc/backend/graphics5/pipeline.c +++ b/armorcore/sources/backends/webgpu/kinc/backend/graphics5/pipeline.c @@ -43,11 +43,11 @@ void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipe) { WGPUVertexAttribute vaDesc[8]; memset(&vaDesc[0], 0, sizeof(vaDesc[0]) * 8); uint64_t offset = 0; - for (int i = 0; i < pipe->inputLayout[0]->size; ++i) { + for (int i = 0; i < pipe->inputLayout->size; ++i) { vaDesc[i].shaderLocation = i; vaDesc[i].offset = offset; - offset += kinc_g4_vertex_data_size(pipe->inputLayout[0]->elements[i].data); - switch (pipe->inputLayout[0]->elements[i].data) { + offset += kinc_g4_vertex_data_size(pipe->inputLayout->elements[i].data); + switch (pipe->inputLayout->elements[i].data) { case KINC_G4_VERTEX_DATA_NONE: vaDesc[i].format = WGPUVertexFormat_Undefined; assert(false); @@ -178,7 +178,7 @@ void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipe) { WGPUVertexBufferLayout vbDesc; memset(&vbDesc, 0, sizeof(vbDesc)); vbDesc.arrayStride = offset; - vbDesc.attributeCount = pipe->inputLayout[0]->size; + vbDesc.attributeCount = pipe->inputLayout->size; vbDesc.attributes = &vaDesc[0]; WGPUVertexState vsDest; diff --git a/armorcore/sources/backends/webgpu/kinc/backend/graphics5/vertexbuffer.c b/armorcore/sources/backends/webgpu/kinc/backend/graphics5/vertexbuffer.c index ad7e81b0..61e2a9d2 100644 --- a/armorcore/sources/backends/webgpu/kinc/backend/graphics5/vertexbuffer.c +++ b/armorcore/sources/backends/webgpu/kinc/backend/graphics5/vertexbuffer.c @@ -7,7 +7,7 @@ extern WGPUDevice device; kinc_g5_vertex_buffer_t *kinc_g5_internal_current_vertex_buffer = NULL; -void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int count, kinc_g5_vertex_structure_t *structure, bool gpuMemory, int instanceDataStepRate) { +void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int count, kinc_g5_vertex_structure_t *structure, bool gpuMemory) { buffer->impl.count = count; buffer->impl.stride = 0; for (int i = 0; i < structure->size; ++i) { diff --git a/armorcore/sources/iron.h b/armorcore/sources/iron.h index 10d195f4..ae1215f7 100644 --- a/armorcore/sources/iron.h +++ b/armorcore/sources/iron.h @@ -204,7 +204,7 @@ int last_window_height = 0; char temp_string[1024 * 32]; char temp_string_vs[1024 * 128]; char temp_string_fs[1024 * 128]; -char temp_string_vstruct[4][32][32]; +char temp_string_vstruct[32][32]; #ifdef KINC_WINDOWS wchar_t temp_wstring[1024 * 32]; struct HWND__ *kinc_windows_window_handle(int window_index); @@ -1052,18 +1052,18 @@ typedef struct kinc_vertex_elem { int data; // vertex_data_t } kinc_vertex_elem_t; -any iron_g4_create_vertex_buffer(i32 count, any_array_t *elements, i32 usage, i32 inst_data_step_rate) { +any iron_g4_create_vertex_buffer(i32 count, any_array_t *elements, i32 usage) { kinc_g4_vertex_structure_t structure; kinc_g4_vertex_structure_init(&structure); for (int32_t i = 0; i < elements->length; ++i) { kinc_vertex_elem_t *element = elements->buffer[i]; char *str = element->name; int32_t data = element->data; - strcpy(temp_string_vstruct[0][i], str); - kinc_g4_vertex_structure_add(&structure, temp_string_vstruct[0][i], (kinc_g4_vertex_data_t)data); + strcpy(temp_string_vstruct[i], str); + kinc_g4_vertex_structure_add(&structure, temp_string_vstruct[i], (kinc_g4_vertex_data_t)data); } kinc_g4_vertex_buffer_t *buffer = (kinc_g4_vertex_buffer_t *)malloc(sizeof(kinc_g4_vertex_buffer_t)); - kinc_g4_vertex_buffer_init(buffer, count, &structure, (kinc_g4_usage_t)usage, inst_data_step_rate); + kinc_g4_vertex_buffer_init(buffer, count, &structure, (kinc_g4_usage_t)usage); return buffer; } @@ -1088,10 +1088,6 @@ void iron_g4_set_vertex_buffer(kinc_g4_vertex_buffer_t *buffer) { kinc_g4_set_vertex_buffer(buffer); } -void iron_g4_set_vertex_buffers(any_array_t *vertex_buffers) { - kinc_g4_set_vertex_buffers(vertex_buffers->buffer, vertex_buffers->length); -} - void iron_g4_draw_indexed_vertices(i32 start, i32 count) { #ifdef KINC_DIRECT3D12 // TODO: Prevent heapIndex overflow in texture.c.h/kinc_g5_internal_set_textures @@ -1105,15 +1101,6 @@ void iron_g4_draw_indexed_vertices(i32 start, i32 count) { } } -void iron_g4_draw_indexed_vertices_instanced(i32 instance_count, i32 start, i32 count) { - if (count < 0) { - kinc_g4_draw_indexed_vertices_instanced(instance_count); - } - else { - kinc_g4_draw_indexed_vertices_instanced_from_to(instance_count, start, count); - } -} - kinc_g4_shader_t *iron_g4_create_shader(buffer_t *data, i32 shader_type) { kinc_g4_shader_t *shader = (kinc_g4_shader_t *)malloc(sizeof(kinc_g4_shader_t)); kinc_g4_shader_init(shader, data->buffer, data->length, (kinc_g4_shader_type_t)shader_type); @@ -1407,7 +1394,6 @@ void iron_g4_delete_pipeline(kinc_g4_pipeline_t *pipeline) { typedef struct vertex_struct { any_array_t *elements; // kinc_vertex_elem_t - bool instanced; } vertex_struct_t; typedef struct iron_pipeline_state { @@ -1427,33 +1413,20 @@ typedef struct iron_pipeline_state { int depth_attachment_bits; } iron_pipeline_state_t; -void iron_g4_compile_pipeline(kinc_g4_pipeline_t *pipeline, vertex_struct_t *structure0, vertex_struct_t *structure1, vertex_struct_t *structure2, vertex_struct_t *structure3, i32 length, kinc_g4_shader_t *vertex_shader, kinc_g4_shader_t *fragment_shader, iron_pipeline_state_t *state) { - kinc_g4_vertex_structure_t s0, s1, s2, s3; +void iron_g4_compile_pipeline(kinc_g4_pipeline_t *pipeline, vertex_struct_t *structure0, kinc_g4_shader_t *vertex_shader, kinc_g4_shader_t *fragment_shader, iron_pipeline_state_t *state) { + kinc_g4_vertex_structure_t s0; kinc_g4_vertex_structure_init(&s0); - kinc_g4_vertex_structure_init(&s1); - kinc_g4_vertex_structure_init(&s2); - kinc_g4_vertex_structure_init(&s3); - kinc_g4_vertex_structure_t *structures[4] = { &s0, &s1, &s2, &s3 }; - for (int32_t i1 = 0; i1 < length; ++i1) { - vertex_struct_t *structure = i1 == 0 ? structure0 : i1 == 1 ? structure1 : i1 == 2 ? structure2 : structure3; - structures[i1]->instanced = structure->instanced; - any_array_t *elements = structure->elements; - for (int32_t i2 = 0; i2 < elements->length; ++i2) { - kinc_vertex_elem_t *element = elements->buffer[i2]; - char *str = element->name; - int32_t data = element->data; - strcpy(temp_string_vstruct[i1][i2], str); - kinc_g4_vertex_structure_add(structures[i1], temp_string_vstruct[i1][i2], (kinc_g4_vertex_data_t)data); - } + any_array_t *elements = structure0->elements; + for (int32_t i = 0; i < elements->length; ++i) { + kinc_vertex_elem_t *element = elements->buffer[i]; + strcpy(temp_string_vstruct[i], element->name); + kinc_g4_vertex_structure_add(&s0, temp_string_vstruct[i], (kinc_g4_vertex_data_t)element->data); } pipeline->vertex_shader = vertex_shader; pipeline->fragment_shader = fragment_shader; - for (int i = 0; i < length; ++i) { - pipeline->input_layout[i] = structures[i]; - } - pipeline->input_layout[length] = NULL; + pipeline->input_layout = &s0; pipeline->cull_mode = (kinc_g4_cull_mode_t)state->cull_mode; pipeline->depth_write = state->depth_write; diff --git a/armorcore/sources/iron_ui_nodes.c b/armorcore/sources/iron_ui_nodes.c index 9add61e6..3932b998 100644 --- a/armorcore/sources/iron_ui_nodes.c +++ b/armorcore/sources/iron_ui_nodes.c @@ -10,6 +10,7 @@ #include "iron_ui.h" #include "iron_ui_ext.h" #include "iron_armpack.h" +#include "iron_array.h" #include "iron_json.h" #include "iron_gc.h" @@ -271,9 +272,13 @@ void ui_draw_link(float x1, float y1, float x2, float y2, bool highlight) { kinc_g2_draw_line_aa(x1, y1, x2, y2, 1.0); } else if (current->ops->theme->LINK_STYLE == UI_LINK_STYLE_CUBIC_BEZIER) { + f32_array_t xa; + f32_array_t ya; float x[] = { x1, x1 + fabs(x1 - x2) / 2.0, x2 - fabs(x1 - x2) / 2.0, x2 }; float y[] = { y1, y1, y2, y2 }; - kinc_g2_draw_cubic_bezier(x, y, 30, highlight ? 2.0 : 1.0); + xa.buffer = x; + ya.buffer = y; + kinc_g2_draw_cubic_bezier(&xa, &ya, 30, highlight ? 2.0 : 1.0); } } diff --git a/armorcore/sources/kinc/graphics2/g2.c b/armorcore/sources/kinc/graphics2/g2.c index 15771b95..b0c15203 100644 --- a/armorcore/sources/kinc/graphics2/g2.c +++ b/armorcore/sources/kinc/graphics2/g2.c @@ -153,8 +153,7 @@ void kinc_g2_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *colored_ kinc_g4_vertex_structure_add(&structure, "tex", KINC_G4_VERTEX_DATA_F32_2X); kinc_g4_vertex_structure_add(&structure, "col", KINC_G4_VERTEX_DATA_U8_4X_NORMALIZED); kinc_g4_pipeline_init(&image_pipeline); - image_pipeline.input_layout[0] = &structure; - image_pipeline.input_layout[1] = NULL; + image_pipeline.input_layout = &structure; image_pipeline.vertex_shader = &image_vert_shader; image_pipeline.fragment_shader = &image_frag_shader; image_pipeline.blend_source = KINC_G4_BLEND_ONE; @@ -166,7 +165,7 @@ void kinc_g2_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *colored_ image_tex_unit = kinc_g4_pipeline_get_texture_unit(&image_pipeline, "tex"); image_proj_loc = kinc_g4_pipeline_get_constant_location(&image_pipeline, "P"); - kinc_g4_vertex_buffer_init(&image_vertex_buffer, G2_BUFFER_SIZE * 4, &structure, KINC_G4_USAGE_DYNAMIC, 0); + kinc_g4_vertex_buffer_init(&image_vertex_buffer, G2_BUFFER_SIZE * 4, &structure, KINC_G4_USAGE_DYNAMIC); image_rect_verts = kinc_g4_vertex_buffer_lock_all(&image_vertex_buffer); kinc_g4_index_buffer_init(&image_index_buffer, G2_BUFFER_SIZE * 3 * 2, KINC_G4_INDEX_BUFFER_FORMAT_32BIT, KINC_G4_USAGE_STATIC); @@ -192,8 +191,7 @@ void kinc_g2_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *colored_ kinc_g4_vertex_structure_add(&structure, "pos", KINC_G4_VERTEX_DATA_F32_3X); kinc_g4_vertex_structure_add(&structure, "col", KINC_G4_VERTEX_DATA_U8_4X_NORMALIZED); kinc_g4_pipeline_init(&colored_pipeline); - colored_pipeline.input_layout[0] = &structure; - colored_pipeline.input_layout[1] = NULL; + colored_pipeline.input_layout = &structure; colored_pipeline.vertex_shader = &colored_vert_shader; colored_pipeline.fragment_shader = &colored_frag_shader; // colored_pipeline.blend_source = KINC_G4_BLEND_ONE; @@ -205,7 +203,7 @@ void kinc_g2_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *colored_ colored_proj_loc = kinc_g4_pipeline_get_constant_location(&colored_pipeline, "P"); - kinc_g4_vertex_buffer_init(&colored_rect_vertex_buffer, G2_BUFFER_SIZE * 4, &structure, KINC_G4_USAGE_DYNAMIC, 0); + kinc_g4_vertex_buffer_init(&colored_rect_vertex_buffer, G2_BUFFER_SIZE * 4, &structure, KINC_G4_USAGE_DYNAMIC); colored_rect_verts = kinc_g4_vertex_buffer_lock_all(&colored_rect_vertex_buffer); kinc_g4_index_buffer_init(&colored_rect_index_buffer, G2_BUFFER_SIZE * 3 * 2, KINC_G4_INDEX_BUFFER_FORMAT_32BIT, KINC_G4_USAGE_STATIC); @@ -220,7 +218,7 @@ void kinc_g2_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *colored_ } kinc_g4_index_buffer_unlock_all(&colored_rect_index_buffer); - kinc_g4_vertex_buffer_init(&colored_tris_vertex_buffer, G2_BUFFER_SIZE * 3, &structure, KINC_G4_USAGE_DYNAMIC, 0); + kinc_g4_vertex_buffer_init(&colored_tris_vertex_buffer, G2_BUFFER_SIZE * 3, &structure, KINC_G4_USAGE_DYNAMIC); colored_tris_verts = kinc_g4_vertex_buffer_lock_all(&colored_tris_vertex_buffer); kinc_g4_index_buffer_init(&colored_tris_index_buffer, G2_BUFFER_SIZE * 3, KINC_G4_INDEX_BUFFER_FORMAT_32BIT, KINC_G4_USAGE_STATIC); @@ -245,8 +243,7 @@ void kinc_g2_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *colored_ kinc_g4_vertex_structure_add(&structure, "col", KINC_G4_VERTEX_DATA_U8_4X_NORMALIZED); kinc_g4_pipeline_init(&text_pipeline); - text_pipeline.input_layout[0] = &structure; - text_pipeline.input_layout[1] = NULL; + text_pipeline.input_layout = &structure; text_pipeline.vertex_shader = &text_vert_shader; text_pipeline.fragment_shader = &text_frag_shader; text_pipeline.blend_source = KINC_G4_BLEND_SOURCE_ALPHA; @@ -258,8 +255,7 @@ void kinc_g2_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *colored_ text_proj_loc = kinc_g4_pipeline_get_constant_location(&text_pipeline, "P"); kinc_g4_pipeline_init(&text_pipeline_rt); - text_pipeline_rt.input_layout[0] = &structure; - text_pipeline_rt.input_layout[1] = NULL; + text_pipeline_rt.input_layout = &structure; text_pipeline_rt.vertex_shader = &text_vert_shader; text_pipeline_rt.fragment_shader = &text_frag_shader; text_pipeline_rt.blend_source = KINC_G4_BLEND_SOURCE_ALPHA; @@ -267,10 +263,8 @@ void kinc_g2_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *colored_ text_pipeline_rt.alpha_blend_source = KINC_G4_BLEND_ONE; text_pipeline_rt.alpha_blend_destination = KINC_G4_BLEND_INV_SOURCE_ALPHA; kinc_g4_pipeline_compile(&text_pipeline_rt); - // text_tex_unit_rt = kinc_g4_pipeline_get_texture_unit(&text_pipeline_rt, "tex"); - // text_proj_loc_rt = kinc_g4_pipeline_get_constant_location(&text_pipeline_rt, "P"); - kinc_g4_vertex_buffer_init(&text_vertex_buffer, G2_BUFFER_SIZE * 4, &structure, KINC_G4_USAGE_DYNAMIC, 0); + kinc_g4_vertex_buffer_init(&text_vertex_buffer, G2_BUFFER_SIZE * 4, &structure, KINC_G4_USAGE_DYNAMIC); text_rect_verts = kinc_g4_vertex_buffer_lock_all(&text_vertex_buffer); kinc_g4_index_buffer_init(&text_index_buffer, G2_BUFFER_SIZE * 3 * 2, KINC_G4_INDEX_BUFFER_FORMAT_32BIT, KINC_G4_USAGE_STATIC); @@ -369,7 +363,12 @@ void kinc_g2_draw_image_buffer(bool end) { void kinc_g2_draw_scaled_sub_texture(kinc_g4_texture_t *tex, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) { kinc_g2_colored_end(); kinc_g2_text_end(); - if (image_buffer_start + image_buffer_index + 1 >= G2_BUFFER_SIZE || (image_last_texture != NULL && tex != image_last_texture) || image_last_render_target != NULL) kinc_g2_draw_image_buffer(false); + if (image_buffer_start + image_buffer_index + 1 >= G2_BUFFER_SIZE || + (image_last_texture != NULL && tex != image_last_texture) || + image_last_render_target != NULL) { + + kinc_g2_draw_image_buffer(false); + } kinc_g2_set_image_rect_tex_coords(sx / tex->tex_width, sy / tex->tex_height, (sx + sw) / tex->tex_width, (sy + sh) / tex->tex_height); kinc_g2_set_image_rect_colors(g2_color); @@ -397,7 +396,12 @@ void kinc_g2_draw_image(kinc_g4_texture_t *tex, float x, float y) { void kinc_g2_draw_scaled_sub_render_target(kinc_g4_render_target_t *rt, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) { kinc_g2_colored_end(); kinc_g2_text_end(); - if (image_buffer_start + image_buffer_index + 1 >= G2_BUFFER_SIZE || (image_last_render_target != NULL && rt != image_last_render_target) || image_last_texture != NULL) kinc_g2_draw_image_buffer(false); + if (image_buffer_start + image_buffer_index + 1 >= G2_BUFFER_SIZE || + (image_last_render_target != NULL && rt != image_last_render_target) || + image_last_texture != NULL) { + + kinc_g2_draw_image_buffer(false); + } kinc_g2_set_image_rect_tex_coords(sx / rt->width, sy / rt->height, (sx + sw) / rt->width, (sy + sh) / rt->height); kinc_g2_set_image_rect_colors(g2_color); diff --git a/armorcore/sources/kinc/graphics4/graphics.h b/armorcore/sources/kinc/graphics4/graphics.h index 6f159924..412f974b 100644 --- a/armorcore/sources/kinc/graphics4/graphics.h +++ b/armorcore/sources/kinc/graphics4/graphics.h @@ -56,8 +56,6 @@ void kinc_g4_scissor(int x, int y, int width, int height); void kinc_g4_disable_scissor(void); void kinc_g4_draw_indexed_vertices(void); void kinc_g4_draw_indexed_vertices_from_to(int start, int count); -void kinc_g4_draw_indexed_vertices_instanced(int instanceCount); -void kinc_g4_draw_indexed_vertices_instanced_from_to(int instanceCount, int start, int count); void kinc_g4_set_texture_addressing(kinc_g4_texture_unit_t unit, kinc_g4_texture_direction_t dir, kinc_g4_texture_addressing_t addressing); void kinc_g4_set_pipeline(struct kinc_g4_pipeline *pipeline); void kinc_g4_set_int(kinc_g4_constant_location_t location, int value); diff --git a/armorcore/sources/kinc/graphics4/pipeline.c.h b/armorcore/sources/kinc/graphics4/pipeline.c.h index 47721c33..5a365ba9 100644 --- a/armorcore/sources/kinc/graphics4/pipeline.c.h +++ b/armorcore/sources/kinc/graphics4/pipeline.c.h @@ -3,9 +3,8 @@ #include void kinc_g4_internal_pipeline_set_defaults(kinc_g4_pipeline_t *state) { - for (int i = 0; i < 16; ++i) { - state->input_layout[i] = NULL; - } + state->input_layout = NULL; + state->vertex_shader = NULL; state->fragment_shader = NULL; diff --git a/armorcore/sources/kinc/graphics4/pipeline.h b/armorcore/sources/kinc/graphics4/pipeline.h index 536fba5e..ba0ad4c2 100644 --- a/armorcore/sources/kinc/graphics4/pipeline.h +++ b/armorcore/sources/kinc/graphics4/pipeline.h @@ -56,7 +56,7 @@ typedef enum { } kinc_g4_cull_mode_t; typedef struct kinc_g4_pipeline { - struct kinc_g4_vertex_structure *input_layout[16]; + struct kinc_g4_vertex_structure *input_layout; struct kinc_g4_shader *vertex_shader; struct kinc_g4_shader *fragment_shader; diff --git a/armorcore/sources/kinc/graphics4/vertexbuffer.c.h b/armorcore/sources/kinc/graphics4/vertexbuffer.c.h index 85cda64b..62ab0535 100644 --- a/armorcore/sources/kinc/graphics4/vertexbuffer.c.h +++ b/armorcore/sources/kinc/graphics4/vertexbuffer.c.h @@ -7,14 +7,8 @@ static void init_vertex_element(kinc_g4_vertex_element_t *element, const char *n void kinc_g4_vertex_structure_init(kinc_g4_vertex_structure_t *structure) { structure->size = 0; - structure->instanced = false; } void kinc_g4_vertex_structure_add(kinc_g4_vertex_structure_t *structure, const char *name, kinc_g4_vertex_data_t data) { init_vertex_element(&structure->elements[structure->size++], name, data); } - -void kinc_g4_set_vertex_buffer(kinc_g4_vertex_buffer_t *buffer) { - kinc_g4_vertex_buffer_t *buffers[1] = {buffer}; - kinc_g4_set_vertex_buffers(buffers, 1); -} diff --git a/armorcore/sources/kinc/graphics4/vertexbuffer.h b/armorcore/sources/kinc/graphics4/vertexbuffer.h index 0dce7963..d9c69a15 100644 --- a/armorcore/sources/kinc/graphics4/vertexbuffer.h +++ b/armorcore/sources/kinc/graphics4/vertexbuffer.h @@ -17,7 +17,7 @@ typedef struct kinc_g4_vertex_buffer { kinc_g4_vertex_buffer_impl_t impl; } kinc_g4_vertex_buffer_t; -void kinc_g4_vertex_buffer_init(kinc_g4_vertex_buffer_t *buffer, int count, kinc_g4_vertex_structure_t *structure, kinc_g4_usage_t usage, int instance_data_step_rate); +void kinc_g4_vertex_buffer_init(kinc_g4_vertex_buffer_t *buffer, int count, kinc_g4_vertex_structure_t *structure, kinc_g4_usage_t usage); void kinc_g4_vertex_buffer_destroy(kinc_g4_vertex_buffer_t *buffer); float *kinc_g4_vertex_buffer_lock_all(kinc_g4_vertex_buffer_t *buffer); float *kinc_g4_vertex_buffer_lock(kinc_g4_vertex_buffer_t *buffer, int start, int count); @@ -25,6 +25,4 @@ void kinc_g4_vertex_buffer_unlock_all(kinc_g4_vertex_buffer_t *buffer); void kinc_g4_vertex_buffer_unlock(kinc_g4_vertex_buffer_t *buffer, int count); int kinc_g4_vertex_buffer_count(kinc_g4_vertex_buffer_t *buffer); int kinc_g4_vertex_buffer_stride(kinc_g4_vertex_buffer_t *buffer); -int kinc_internal_g4_vertex_buffer_set(kinc_g4_vertex_buffer_t *buffer, int offset); -void kinc_g4_set_vertex_buffers(kinc_g4_vertex_buffer_t **buffers, int count); void kinc_g4_set_vertex_buffer(kinc_g4_vertex_buffer_t *buffer); diff --git a/armorcore/sources/kinc/graphics4/vertexstructure.h b/armorcore/sources/kinc/graphics4/vertexstructure.h index 5a4e2806..8ed9ea5c 100644 --- a/armorcore/sources/kinc/graphics4/vertexstructure.h +++ b/armorcore/sources/kinc/graphics4/vertexstructure.h @@ -119,7 +119,6 @@ typedef struct kinc_g4_vertex_element { typedef struct kinc_g4_vertex_structure { kinc_g4_vertex_element_t elements[KINC_G4_MAX_VERTEX_ELEMENTS]; int size; - bool instanced; } kinc_g4_vertex_structure_t; void kinc_g4_vertex_structure_init(kinc_g4_vertex_structure_t *structure); diff --git a/armorcore/sources/kinc/graphics5/commandlist.h b/armorcore/sources/kinc/graphics5/commandlist.h index 817d6fa1..24c0d01b 100644 --- a/armorcore/sources/kinc/graphics5/commandlist.h +++ b/armorcore/sources/kinc/graphics5/commandlist.h @@ -42,14 +42,12 @@ void kinc_g5_command_list_texture_to_render_target_barrier(kinc_g5_command_list_ void kinc_g5_command_list_render_target_to_texture_barrier(kinc_g5_command_list_t *list, struct kinc_g5_render_target *renderTarget); void kinc_g5_command_list_draw_indexed_vertices(kinc_g5_command_list_t *list); void kinc_g5_command_list_draw_indexed_vertices_from_to(kinc_g5_command_list_t *list, int start, int count); -void kinc_g5_command_list_draw_indexed_vertices_instanced(kinc_g5_command_list_t *list, int instanceCount); -void kinc_g5_command_list_draw_indexed_vertices_instanced_from_to(kinc_g5_command_list_t *list, int instanceCount, int start, int count); void kinc_g5_command_list_viewport(kinc_g5_command_list_t *list, int x, int y, int width, int height); void kinc_g5_command_list_scissor(kinc_g5_command_list_t *list, int x, int y, int width, int height); void kinc_g5_command_list_disable_scissor(kinc_g5_command_list_t *list); void kinc_g5_command_list_set_pipeline(kinc_g5_command_list_t *list, struct kinc_g5_pipeline *pipeline); void kinc_g5_command_list_set_compute_shader(kinc_g5_command_list_t *list, struct kinc_g5_compute_shader *shader); -void kinc_g5_command_list_set_vertex_buffers(kinc_g5_command_list_t *list, struct kinc_g5_vertex_buffer **buffers, int *offsets, int count); +void kinc_g5_command_list_set_vertex_buffer(kinc_g5_command_list_t *list, struct kinc_g5_vertex_buffer *buffer); void kinc_g5_command_list_set_index_buffer(kinc_g5_command_list_t *list, struct kinc_g5_index_buffer *buffer); void kinc_g5_command_list_set_render_targets(kinc_g5_command_list_t *list, struct kinc_g5_render_target **targets, int count); void kinc_g5_command_list_upload_index_buffer(kinc_g5_command_list_t *list, struct kinc_g5_index_buffer *buffer); diff --git a/armorcore/sources/kinc/graphics5/pipeline.c.h b/armorcore/sources/kinc/graphics5/pipeline.c.h index 2f6244bb..07bc1ca6 100644 --- a/armorcore/sources/kinc/graphics5/pipeline.c.h +++ b/armorcore/sources/kinc/graphics5/pipeline.c.h @@ -1,9 +1,8 @@ #include "pipeline.h" void kinc_g5_internal_pipeline_init(kinc_g5_pipeline_t *pipe) { - for (int i = 0; i < 16; ++i) { - pipe->inputLayout[i] = NULL; - } + pipe->inputLayout = NULL; + pipe->vertexShader = NULL; pipe->fragmentShader = NULL; diff --git a/armorcore/sources/kinc/graphics5/pipeline.h b/armorcore/sources/kinc/graphics5/pipeline.h index b2699995..e0141895 100644 --- a/armorcore/sources/kinc/graphics5/pipeline.h +++ b/armorcore/sources/kinc/graphics5/pipeline.h @@ -54,7 +54,7 @@ typedef enum kinc_g5_compare_mode { } kinc_g5_compare_mode_t; typedef struct kinc_g5_pipeline { - kinc_g5_vertex_structure_t *inputLayout[16]; + kinc_g5_vertex_structure_t *inputLayout; struct kinc_g5_shader *vertexShader; struct kinc_g5_shader *fragmentShader; diff --git a/armorcore/sources/kinc/graphics5/vertexbuffer.h b/armorcore/sources/kinc/graphics5/vertexbuffer.h index bf737aaf..5bb6a749 100644 --- a/armorcore/sources/kinc/graphics5/vertexbuffer.h +++ b/armorcore/sources/kinc/graphics5/vertexbuffer.h @@ -14,8 +14,7 @@ typedef struct kinc_g5_vertex_buffer { VertexBuffer5Impl impl; } kinc_g5_vertex_buffer_t; -void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int count, kinc_g5_vertex_structure_t *structure, bool gpu_memory, - int instance_data_step_rate); +void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int count, kinc_g5_vertex_structure_t *structure, bool gpu_memory); void kinc_g5_vertex_buffer_destroy(kinc_g5_vertex_buffer_t *buffer); float *kinc_g5_vertex_buffer_lock_all(kinc_g5_vertex_buffer_t *buffer); float *kinc_g5_vertex_buffer_lock(kinc_g5_vertex_buffer_t *buffer, int start, int count); diff --git a/armorcore/sources/ts/g4.ts b/armorcore/sources/ts/g4.ts index 489175c8..300213f9 100644 --- a/armorcore/sources/ts/g4.ts +++ b/armorcore/sources/ts/g4.ts @@ -79,10 +79,7 @@ function g4_pipeline_delete(raw: pipeline_t) { } function g4_pipeline_compile(raw: pipeline_t) { - let structure0: vertex_struct_t = raw.input_layout.length > 0 ? raw.input_layout[0] : null; - let structure1: vertex_struct_t = raw.input_layout.length > 1 ? raw.input_layout[1] : null; - let structure2: vertex_struct_t = raw.input_layout.length > 2 ? raw.input_layout[2] : null; - let structure3: vertex_struct_t = raw.input_layout.length > 3 ? raw.input_layout[3] : null; + let structure0: vertex_struct_t = raw.input_layout; for (let i: i32 = raw.color_write_masks_red.length; i < 8; ++i) { array_push(raw.color_write_masks_red, true); @@ -113,7 +110,7 @@ function g4_pipeline_compile(raw: pipeline_t) { state.color_attachments = raw.color_attachments; state.depth_attachment_bits = g4_pipeline_get_depth_buffer_bits(raw.depth_attachment); - iron_g4_compile_pipeline(raw.pipeline_, structure0, structure1, structure2, structure3, raw.input_layout.length, raw.vertex_shader.shader_, raw.fragment_shader.shader_, state); + iron_g4_compile_pipeline(raw.pipeline_, structure0, raw.vertex_shader.shader_, raw.fragment_shader.shader_, state); } function g4_pipeline_set(raw: pipeline_t) { @@ -128,10 +125,10 @@ function g4_pipeline_get_tex_unit(raw: pipeline_t, name: string): kinc_tex_unit_ return iron_g4_get_texture_unit(raw.pipeline_, name); } -function g4_vertex_buffer_create(vertex_count: i32, structure: vertex_struct_t, usage: usage_t, inst_data_step_rate: i32 = 0): vertex_buffer_t { +function g4_vertex_buffer_create(vertex_count: i32, structure: vertex_struct_t, usage: usage_t): vertex_buffer_t { let raw: vertex_buffer_t = {}; raw.vertex_count = vertex_count; - raw.buffer_ = iron_g4_create_vertex_buffer(vertex_count, structure.elements, usage, inst_data_step_rate); + raw.buffer_ = iron_g4_create_vertex_buffer(vertex_count, structure.elements, usage); return raw; } @@ -154,7 +151,6 @@ function g4_vertex_buffer_set(raw: vertex_buffer_t) { function g4_vertex_struct_create(): vertex_struct_t { let raw: vertex_struct_t = {}; raw.elements = []; - raw.instanced = false; return raw; } @@ -241,10 +237,6 @@ function g4_set_vertex_buffer(vb: vertex_buffer_t) { g4_vertex_buffer_set(vb); } -function g4_set_vertex_buffers(vbs: any_array_t[]) { - iron_g4_set_vertex_buffers(vbs); -} - function g4_set_index_buffer(ib: index_buffer_t) { g4_index_buffer_set(ib); } @@ -327,10 +319,6 @@ function g4_draw(start: i32 = 0, count: i32 = -1) { iron_g4_draw_indexed_vertices(start, count); } -function g4_draw_inst(inst_count: i32, start: i32 = 0, count: i32 = -1) { - iron_g4_draw_indexed_vertices_instanced(inst_count, start, count); -} - function g4_scissor(x: i32, y: i32, width: i32, height: i32) { iron_g4_scissor(x, y, width, height); } @@ -507,7 +495,7 @@ declare type image_t = { type pipeline_t = { pipeline_?: any; - input_layout?: vertex_struct_t[]; + input_layout?: vertex_struct_t; vertex_shader?: shader_t; fragment_shader?: shader_t; cull_mode?: cull_mode_t; @@ -537,7 +525,6 @@ type vertex_buffer_t = { declare type vertex_struct_t = { elements?: kinc_vertex_elem_t[]; - instanced?: bool; }; type index_buffer_t = { diff --git a/armorcore/sources/ts/iron.ts b/armorcore/sources/ts/iron.ts index cc92efb2..b838257a 100644 --- a/armorcore/sources/ts/iron.ts +++ b/armorcore/sources/ts/iron.ts @@ -216,14 +216,12 @@ declare function iron_g4_delete_index_buffer(buffer: any): void; declare function iron_g4_lock_index_buffer(buffer: any): u32_array_t; declare function iron_g4_unlock_index_buffer(buffer: any): void; declare function iron_g4_set_index_buffer(buffer: any): void; -declare function iron_g4_create_vertex_buffer(count: i32, structure: kinc_vertex_elem_t[], usage: i32, inst_data_step_rate: i32): any; +declare function iron_g4_create_vertex_buffer(count: i32, structure: kinc_vertex_elem_t[], usage: i32): any; declare function iron_g4_delete_vertex_buffer(buffer: any): void; declare function iron_g4_lock_vertex_buffer(buffer: any): buffer_t; declare function iron_g4_unlock_vertex_buffer(buffer: any): void; declare function iron_g4_set_vertex_buffer(buffer: any): void; -declare function iron_g4_set_vertex_buffers(vertex_buffers: vertex_buffer_t[]): void; declare function iron_g4_draw_indexed_vertices(start: i32, count: i32): void; -declare function iron_g4_draw_indexed_vertices_instanced(inst_count: i32, start: i32, count: i32): void; declare function iron_g4_create_shader(data: buffer_t, type: i32): any; declare function iron_g4_create_vertex_shader_from_source(source: string): any; declare function iron_g4_create_fragment_shader_from_source(source: string): any; diff --git a/armorcore/sources/ts/mesh_data.ts b/armorcore/sources/ts/mesh_data.ts index 51d5fef1..15ac2b52 100644 --- a/armorcore/sources/ts/mesh_data.ts +++ b/armorcore/sources/ts/mesh_data.ts @@ -41,8 +41,6 @@ function mesh_data_create(raw: mesh_data_t): mesh_data_t { raw._.refcount = 0; raw._.vertex_buffer_map = map_create(); raw._.ready = false; - raw._.instanced = false; - raw._.instance_count = 0; // Mesh data let indices: u32_array_t[] = []; @@ -167,28 +165,6 @@ function mesh_data_get_vertex_array(raw: mesh_data_t, name: string): vertex_arra return null; } -function mesh_data_setup_inst(raw: mesh_data_t, data: f32_array_t, inst_type: i32) { - let structure: vertex_struct_t = g4_vertex_struct_create(); - structure.instanced = true; - raw._.instanced = true; - // pos, pos+rot, pos+scale, pos+rot+scale - g4_vertex_struct_add(structure, "ipos", vertex_data_t.F32_3X); - if (inst_type == 2 || inst_type == 4) { - g4_vertex_struct_add(structure, "irot", vertex_data_t.F32_3X); - } - if (inst_type == 3 || inst_type == 4) { - g4_vertex_struct_add(structure, "iscl", vertex_data_t.F32_3X); - } - - raw._.instance_count = math_floor(data.length / math_floor(g4_vertex_struct_byte_size(structure) / 4)); - raw._.instanced_vb = g4_vertex_buffer_create(raw._.instance_count, structure, usage_t.STATIC, 1); - let vertices: buffer_t = g4_vertex_buffer_lock(raw._.instanced_vb); - for (let i: i32 = 0; i < math_floor((vertices.length) / 4); ++i) { - buffer_set_f32(vertices, i * 4, data[i]); - } - g4_vertex_buffer_unlock(raw._.instanced_vb); -} - function mesh_data_get(raw: mesh_data_t, vs: vertex_element_t[]): vertex_buffer_t { let key: string = ""; for (let i: i32 = 0; i < vs.length; ++i) { @@ -274,11 +250,6 @@ function mesh_data_build(raw: mesh_data_t) { array_push(raw._.index_buffers, index_buffer); } - // Instanced - if (raw.instancing != null) { - mesh_data_setup_inst(raw, raw.instancing.data, raw.instancing.type); - } - raw._.ready = true; } diff --git a/armorcore/sources/ts/mesh_object.ts b/armorcore/sources/ts/mesh_object.ts index dfe5db80..47b6d882 100644 --- a/armorcore/sources/ts/mesh_object.ts +++ b/armorcore/sources/ts/mesh_object.ts @@ -144,9 +144,6 @@ function mesh_object_cull_mesh(raw: mesh_object_t, context: string, camera: came radius_scale *= 1000; } ///end - if (raw.data._.instanced) { - radius_scale *= 100; - } let frustum_planes: frustum_plane_t[] = camera.frustum_planes; if (!camera_object_sphere_in_frustum(frustum_planes, raw.base.transform, radius_scale)) { @@ -258,25 +255,9 @@ function mesh_object_render(raw: mesh_object_t, context: string, bind_params: st uniforms_set_material_consts(scontext, material_contexts[mi]); } - // VB / IB - if (raw.data._.instanced_vb != null) { - let vb: vertex_buffer_t = mesh_data_get(raw.data, elems); - let vbs: vertex_buffer_t[] = [vb.buffer_, raw.data._.instanced_vb.buffer_]; - g4_set_vertex_buffers(vbs); - } - else { - g4_set_vertex_buffer(mesh_data_get(raw.data, elems)); - } - + g4_set_vertex_buffer(mesh_data_get(raw.data, elems)); g4_set_index_buffer(raw.data._.index_buffers[i]); - - // Draw - if (raw.data._.instanced) { - g4_draw_inst(raw.data._.instance_count, 0, -1); - } - else { - g4_draw(0, -1); - } + g4_draw(); } raw.prev_matrix = mat4_clone(raw.base.transform.world_unpack); diff --git a/armorcore/sources/ts/particle_sys.ts b/armorcore/sources/ts/particle_sys.ts index 69dae956..a3d1ae2c 100644 --- a/armorcore/sources/ts/particle_sys.ts +++ b/armorcore/sources/ts/particle_sys.ts @@ -147,9 +147,7 @@ function particle_sys_get_data(raw: particle_sys_t): mat4_t { } function particle_sys_update_gpu(raw: particle_sys_t, object: mesh_object_t, owner: mesh_object_t) { - if (!object.data._.instanced) { - particle_sys_setup_geom(raw, object, owner); - } + particle_sys_setup_geom(raw, object, owner); // GPU particles transform is attached to owner object } @@ -221,8 +219,6 @@ function particle_sys_setup_geom(raw: particle_sys_t, object: mesh_object_t, own i++; } } - - mesh_data_setup_inst(object.data, instanced_data, 1); } function particle_sys_fhash(n: i32): f32 { diff --git a/armorcore/sources/ts/scene.ts b/armorcore/sources/ts/scene.ts index 8c0b732a..78d231d2 100644 --- a/armorcore/sources/ts/scene.ts +++ b/armorcore/sources/ts/scene.ts @@ -504,7 +504,6 @@ type mesh_data_t = { name?: string; scale_pos?: f32; // Unpack pos from (-1,1) coords scale_tex?: f32; // Unpack tex from (-1,1) coords - instancing?: mesh_data_instancing_t; skin?: skin_t; vertex_arrays?: vertex_array_t[]; index_arrays?: index_array_t[]; @@ -522,9 +521,6 @@ type mesh_data_runtime_t = { indices?: u32_array_t[]; material_indices?: i32[]; structure?: vertex_struct_t; - instanced_vb?: vertex_buffer_t; - instanced?: bool; - instance_count?: i32; ///if arm_skin skeleton_transforms_inv?: mat4_t[]; actions?: map_t; @@ -532,11 +528,6 @@ type mesh_data_runtime_t = { ///end }; -type mesh_data_instancing_t = { - type?: i32; // off, loc, loc+rot, loc+scale, loc+rot+scale - data?: f32_array_t; -}; - type skin_t = { transform?: f32_array_t; bone_ref_array?: string[]; @@ -659,7 +650,6 @@ type shader_context_runtime_t = { tex_units?: kinc_tex_unit_t[]; override_context?: _shader_override_t; structure?: vertex_struct_t; - instancing_type?: i32; }; type _shader_override_t = { diff --git a/armorcore/sources/ts/shader_data.ts b/armorcore/sources/ts/shader_data.ts index 2361eea1..1e8bcd8f 100644 --- a/armorcore/sources/ts/shader_data.ts +++ b/armorcore/sources/ts/shader_data.ts @@ -73,21 +73,7 @@ function shader_context_compile(raw: shader_context_t): shader_context_t { raw._.constants = []; raw._.tex_units = []; - if (raw._.instancing_type > 0) { // Instancing - let inst_struct: vertex_struct_t = g4_vertex_struct_create(); - g4_vertex_struct_add(inst_struct, "ipos", vertex_data_t.F32_3X); - if (raw._.instancing_type == 2 || raw._.instancing_type == 4) { - g4_vertex_struct_add(inst_struct, "irot", vertex_data_t.F32_3X); - } - if (raw._.instancing_type == 3 || raw._.instancing_type == 4) { - g4_vertex_struct_add(inst_struct, "iscl", vertex_data_t.F32_3X); - } - inst_struct.instanced = true; - raw._.pipe_state.input_layout = [raw._.structure, inst_struct]; - } - else { // Regular - raw._.pipe_state.input_layout = [raw._.structure]; - } + raw._.pipe_state.input_layout = raw._.structure; // Depth raw._.pipe_state.depth_write = raw.depth_write; @@ -216,37 +202,11 @@ function shader_context_parse_data(data: string): vertex_data_t { function shader_context_parse_vertex_struct(raw: shader_context_t) { raw._.structure = g4_vertex_struct_create(); - let ipos: bool = false; - let irot: bool = false; - let iscl: bool = false; + for (let i: i32 = 0; i < raw.vertex_elements.length; ++i) { let elem: vertex_element_t = raw.vertex_elements[i]; - if (elem.name == "ipos") { - ipos = true; - continue; - } - if (elem.name == "irot") { - irot = true; - continue; - } - if (elem.name == "iscl") { - iscl = true; - continue; - } g4_vertex_struct_add(raw._.structure, elem.name, shader_context_parse_data(elem.data)); } - if (ipos && !irot && !iscl) { - raw._.instancing_type = 1; - } - else if (ipos && irot && !iscl) { - raw._.instancing_type = 2; - } - else if (ipos && !irot && iscl) { - raw._.instancing_type = 3; - } - else if (ipos && irot && iscl) { - raw._.instancing_type = 4; - } } function shader_context_delete(raw: shader_context_t) { diff --git a/armorcore/tools/io_export_arm.py b/armorcore/tools/io_export_arm.py index bc9c7a27..eee4562d 100644 --- a/armorcore/tools/io_export_arm.py +++ b/armorcore/tools/io_export_arm.py @@ -530,7 +530,6 @@ class ArmoryExporter(bpy.types.Operator, ExportHelper): if has_col: cdata = np.empty(num_verts * 4, dtype="KWG_Z*el7+EhRnR;lEl2^%)Imin_C#4F#`a%W(zz3 diff --git a/armorforge/assets/meshes/box_bevel.arm b/armorforge/assets/meshes/box_bevel.arm index 34f0b5c13814b7644bbea594aa2da371780cd02c..0801e52eaa7434f9fda13fceab35b8a270692adc 100644 GIT binary patch delta 20 ccmex0i}BSg#toi~jBJy=7_B!?Wqj%l09MQgt^fc4 delta 36 scmaDgi}BYi#toi~jO>%W7_Ira7#J8b^NLFn^O7_3(hqEIVSMHd0N{-brT_o{ diff --git a/armorforge/assets/meshes/cone.arm b/armorforge/assets/meshes/cone.arm index c7e0df5ff9a3bae26751a2b739cb08ec28e3b8f6..dce1154fa95c040ba75845594aac697188af28f5 100644 GIT binary patch delta 18 acmca=bkt~rHzOn4WFJPG%`+JHiUR;Y%LYCG delta 34 qcmX?Vbk%5sHzOnaWFJNwel7+EhRnR;lEl2^%)Imio7)-pi30$*EDJUO diff --git a/armorforge/assets/meshes/cylinder.arm b/armorforge/assets/meshes/cylinder.arm index dddcfbb441f5cd565ca61aae20c2c8479ecce712..c450534f0c567263853b9472bd304e8514d89041 100644 GIT binary patch delta 21 dcmX@1prmt2TA|{ delta 37 tcmdn#chYY|Fe4-TL~W_bd5miOTnr2hnR&$}iFwJHdFcl>Pi9=E3IN{V3_<_^ diff --git a/armorforge/assets/meshes/sphere.arm b/armorforge/assets/meshes/sphere.arm index bc082acb857228a7417f43b79ec8750c8b7b6ddb..87e61e79889ca7cca609d9b64fc56ffd3927d0cb 100644 GIT binary patch delta 28 kcmezTitF(!t_}W-jBJww810(pF}BZRWZXWFk?HDY0IZ7(5dZ)H delta 44 zcmaF-itF<$t_}W-jO>#G814AE7#J8b^NLFn^O7_3(hoHEGPd_JGH&l>WV*H)0BBVY A=Kufz diff --git a/armorforge/assets/meshes/torus.arm b/armorforge/assets/meshes/torus.arm index 2a8f6bf6f4c6cc1869e41703b76cca0df7200a4f..2008599a9051e9a618203931b8659c3945b1a6c2 100644 GIT binary patch delta 32 mcmeycjpxBOo(;Z?jBJzr7;T$pGq%rW1YxG_vl*GMN&*1NbPFW_ delta 48 zcmaE`jpxHQo(;Z?jO>&B7;X8v7#J8b^NLFn^O7_3(hoFuF}8Oxf-uweE=J~Sk^quT B59$B_ diff --git a/armorpaint/assets/meshes/cube_shared_uvs.arm b/armorpaint/assets/meshes/cube_shared_uvs.arm index 2532d20f399992976dac792e23a8514c99a0c74e..42b29b7c4bc69871977d42f357f1033e75d3e7e6 100644 GIT binary patch delta 15 WcmZ3?HJNLIAtT#FBb$wNOIZLWMFi>q delta 31 ncmbQtwU}#yAtU=lBO87$1_p-AyyB9?yyVQh^aC4nm$3iwPMz)FCQj=?h)HZJt@=9Z5o9xdhF@I2{5WbL@NcsqSIFi!_-BKK-3Aci%(xH#;5^NXCn?1 zm7Lxt3DYer1rrsYo+<-V`%ea9roKF*^LC)!6M@!F2XdsR>np+3oKS+Rk)AH13KL$d z3K71i&S(ephRk*k4aWV9KwPM)rx?Qj=?h)cCm=7#K41ic1pnk~8zt4{Tm2QAe<=x diff --git a/base/sources/import_envmap.ts b/base/sources/import_envmap.ts index a6ae6bb3..b19e2ee3 100644 --- a/base/sources/import_envmap.ts +++ b/base/sources/import_envmap.ts @@ -17,7 +17,7 @@ function import_envmap_run(path: string, image: image_t) { import_envmap_pipeline.fragment_shader = sys_get_shader("prefilter_envmap.frag"); let vs: vertex_struct_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); - import_envmap_pipeline.input_layout = [vs]; + import_envmap_pipeline.input_layout = vs; import_envmap_pipeline.color_attachment_count = 1; import_envmap_pipeline.color_attachments[0] = tex_format_t.RGBA128; g4_pipeline_compile(import_envmap_pipeline); diff --git a/base/sources/line_draw.ts b/base/sources/line_draw.ts index 132ba945..f4599ff3 100644 --- a/base/sources/line_draw.ts +++ b/base/sources/line_draw.ts @@ -43,7 +43,7 @@ function line_draw_init() { let structure: vertex_struct_t = g4_vertex_struct_create(); g4_vertex_struct_add(structure, "pos", vertex_data_t.F32_3X); line_draw_pipeline = g4_pipeline_create(); - line_draw_pipeline.input_layout = [structure]; + line_draw_pipeline.input_layout = structure; line_draw_pipeline.fragment_shader = sys_get_shader("line.frag"); line_draw_pipeline.vertex_shader = sys_get_shader("line.vert"); line_draw_pipeline.depth_write = true; @@ -65,7 +65,7 @@ function line_draw_init() { let structure: vertex_struct_t = g4_vertex_struct_create(); g4_vertex_struct_add(structure, "pos", vertex_data_t.F32_3X); line_draw_overlay_pipeline = g4_pipeline_create(); - line_draw_overlay_pipeline.input_layout = [structure]; + line_draw_overlay_pipeline.input_layout = structure; line_draw_overlay_pipeline.fragment_shader = sys_get_shader("line_overlay.frag"); line_draw_overlay_pipeline.vertex_shader = sys_get_shader("line.vert"); line_draw_overlay_pipeline.depth_write = true; diff --git a/base/sources/pipes.ts b/base/sources/pipes.ts index 3693f312..f1991077 100644 --- a/base/sources/pipes.ts +++ b/base/sources/pipes.ts @@ -55,7 +55,7 @@ function _pipes_make_merge(red: bool, green: bool, blue: bool, alpha: bool): pip pipe.fragment_shader = sys_get_shader("layer_merge.frag"); let vs: vertex_struct_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); - pipe.input_layout = [vs]; + pipe.input_layout = vs; pipe.color_write_masks_red = [red]; pipe.color_write_masks_green = [green]; pipe.color_write_masks_blue = [blue]; @@ -86,7 +86,7 @@ function pipes_init() { g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); - pipes_copy.input_layout = [vs]; + pipes_copy.input_layout = vs; g4_pipeline_compile(pipes_copy); } @@ -98,7 +98,7 @@ function pipes_init() { g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); - pipes_copy_bgra.input_layout = [vs]; + pipes_copy_bgra.input_layout = vs; g4_pipeline_compile(pipes_copy_bgra); } @@ -110,7 +110,7 @@ function pipes_init() { g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); - pipes_copy8.input_layout = [vs]; + pipes_copy8.input_layout = vs; pipes_copy8.color_attachment_count = 1; pipes_copy8.color_attachments[0] = tex_format_t.R8; g4_pipeline_compile(pipes_copy8); @@ -124,7 +124,7 @@ function pipes_init() { g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); - pipes_copy128.input_layout = [vs]; + pipes_copy128.input_layout = vs; pipes_copy128.color_attachment_count = 1; pipes_copy128.color_attachments[0] = tex_format_t.RGBA128; g4_pipeline_compile(pipes_copy128); @@ -139,7 +139,7 @@ function pipes_init() { g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); - pipes_invert8.input_layout = [vs]; + pipes_invert8.input_layout = vs; pipes_invert8.color_attachment_count = 1; pipes_invert8.color_attachments[0] = tex_format_t.R8; g4_pipeline_compile(pipes_invert8); @@ -151,7 +151,7 @@ function pipes_init() { pipes_apply_mask.fragment_shader = sys_get_shader("mask_apply.frag"); let vs: vertex_struct_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); - pipes_apply_mask.input_layout = [vs]; + pipes_apply_mask.input_layout = vs; g4_pipeline_compile(pipes_apply_mask); pipes_tex0_mask = g4_pipeline_get_tex_unit(pipes_apply_mask, "tex0"); pipes_texa_mask = g4_pipeline_get_tex_unit(pipes_apply_mask, "texa"); @@ -163,7 +163,7 @@ function pipes_init() { pipes_merge_mask.fragment_shader = sys_get_shader("mask_merge.frag"); let vs: vertex_struct_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); - pipes_merge_mask.input_layout = [vs]; + pipes_merge_mask.input_layout = vs; g4_pipeline_compile(pipes_merge_mask); pipes_tex0_merge_mask = g4_pipeline_get_tex_unit(pipes_merge_mask, "tex0"); pipes_texa_merge_mask = g4_pipeline_get_tex_unit(pipes_merge_mask, "texa"); @@ -177,7 +177,7 @@ function pipes_init() { pipes_colorid_to_mask.fragment_shader = sys_get_shader("mask_colorid.frag"); let vs: vertex_struct_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); - pipes_colorid_to_mask.input_layout = [vs]; + pipes_colorid_to_mask.input_layout = vs; g4_pipeline_compile(pipes_colorid_to_mask); pipes_texpaint_colorid = g4_pipeline_get_tex_unit(pipes_colorid_to_mask, "texpaint_colorid"); pipes_tex_colorid = g4_pipeline_get_tex_unit(pipes_colorid_to_mask, "texcolorid"); @@ -193,7 +193,7 @@ function pipes_init() { g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); - pipes_copy_r.input_layout = [vs]; + pipes_copy_r.input_layout = vs; pipes_copy_r.color_write_masks_green = [false]; pipes_copy_r.color_write_masks_blue = [false]; pipes_copy_r.color_write_masks_alpha = [false]; @@ -208,7 +208,7 @@ function pipes_init() { g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); - pipes_copy_g.input_layout = [vs]; + pipes_copy_g.input_layout = vs; pipes_copy_g.color_write_masks_red = [false]; pipes_copy_g.color_write_masks_blue = [false]; pipes_copy_g.color_write_masks_alpha = [false]; @@ -221,7 +221,7 @@ function pipes_init() { pipes_inpaint_preview.fragment_shader = sys_get_shader("inpaint_preview.frag"); let vs: vertex_struct_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); - pipes_inpaint_preview.input_layout = [vs]; + pipes_inpaint_preview.input_layout = vs; g4_pipeline_compile(pipes_inpaint_preview); pipes_tex0_inpaint_preview = g4_pipeline_get_tex_unit(pipes_inpaint_preview, "tex0"); pipes_texa_inpaint_preview = g4_pipeline_get_tex_unit(pipes_inpaint_preview, "texa"); @@ -233,7 +233,7 @@ function pipes_init() { pipes_copy_a.fragment_shader = sys_get_shader("layer_copy_rrrr.frag"); let vs: vertex_struct_t = g4_vertex_struct_create(); g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); - pipes_copy_a.input_layout = [vs]; + pipes_copy_a.input_layout = vs; pipes_copy_a.color_write_masks_red = [false]; pipes_copy_a.color_write_masks_green = [false]; pipes_copy_a.color_write_masks_blue = [false]; @@ -250,7 +250,7 @@ function pipes_init() { g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); - pipes_copy_rgb.input_layout = [vs]; + pipes_copy_rgb.input_layout = vs; pipes_copy_rgb.color_write_masks_alpha = [false]; g4_pipeline_compile(pipes_copy_rgb); } @@ -267,7 +267,7 @@ function pipes_init() { g4_vertex_struct_add(vs, "nor", vertex_data_t.I16_2X_NORM); g4_vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); ///end - pipes_cursor.input_layout = [vs]; + pipes_cursor.input_layout = vs; pipes_cursor.blend_source = blend_factor_t.SOURCE_ALPHA; pipes_cursor.blend_dest = blend_factor_t.INV_SOURCE_ALPHA; pipes_cursor.depth_write = false; diff --git a/base/sources/ui_view2d.ts b/base/sources/ui_view2d.ts index 2f4717fe..ddd62979 100644 --- a/base/sources/ui_view2d.ts +++ b/base/sources/ui_view2d.ts @@ -39,7 +39,7 @@ function ui_view2d_init() { g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); g4_vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); g4_vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); - ui_view2d_pipe.input_layout = [vs]; + ui_view2d_pipe.input_layout = vs; ui_view2d_pipe.blend_source = blend_factor_t.BLEND_ONE; ui_view2d_pipe.blend_dest = blend_factor_t.BLEND_ZERO; ui_view2d_pipe.color_write_masks_alpha[0] = false; diff --git a/base/sources/util_encode.ts b/base/sources/util_encode.ts index bba581a1..651b3f07 100644 --- a/base/sources/util_encode.ts +++ b/base/sources/util_encode.ts @@ -96,8 +96,6 @@ function util_encode_mesh_datas(datas: mesh_data_t[]) { armpack_encode_f32(datas[i].scale_pos); armpack_encode_string("scale_tex"); armpack_encode_f32(datas[i].scale_tex); - armpack_encode_string("instancing"); - armpack_encode_null(); // mesh_data_instancing_t armpack_encode_string("skin"); armpack_encode_null(); // skin_t armpack_encode_string("vertex_arrays"); diff --git a/base/sources/util_uv.ts b/base/sources/util_uv.ts index 746439ee..2cfe2310 100644 --- a/base/sources/util_uv.ts +++ b/base/sources/util_uv.ts @@ -117,7 +117,7 @@ function util_uv_cache_dilate_map() { g4_vertex_struct_add(vs, "nor", vertex_data_t.I16_2X_NORM); g4_vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); ///end - util_uv_pipe_dilate.input_layout = [vs]; + util_uv_pipe_dilate.input_layout = vs; util_uv_pipe_dilate.depth_write = false; util_uv_pipe_dilate.depth_mode = compare_mode_t.ALWAYS; util_uv_pipe_dilate.color_attachments[0] = tex_format_t.R8;