From c9cd9d0b180d10b9ffec51d0d2de893ea860b1ef Mon Sep 17 00:00:00 2001 From: jacob Date: Sun, 8 Jun 2025 16:24:29 -0500 Subject: [PATCH] merge conflict --- src/gpu_dx12.c | 103 +------------------------------------------------ 1 file changed, 2 insertions(+), 101 deletions(-) diff --git a/src/gpu_dx12.c b/src/gpu_dx12.c index 24b0ff54..e80e8a3e 100644 --- a/src/gpu_dx12.c +++ b/src/gpu_dx12.c @@ -27,8 +27,8 @@ #pragma comment(lib, "dxguid") #pragma comment(lib, "d3dcompiler") -//#define DX12_WAIT_FRAME_LATENCY 1 -//#define DX12_ALLOW_TEARING 1 +#define DX12_WAIT_FRAME_LATENCY 1 +#define DX12_ALLOW_TEARING 1 #define DX12_SWAPCHAIN_BUFFER_COUNT (3) #define DX12_SWAPCHAIN_FLAGS ((DX12_ALLOW_TEARING * DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING) | (DX12_WAIT_FRAME_LATENCY * DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT)) @@ -133,12 +133,6 @@ struct gpu_startup_receipt gpu_startup(struct work_startup_receipt *work_sr, str { __prof; (UNUSED)work_sr; - -======= -INTERNAL void dx12_init_shaders(void); - -struct gpu_startup_receipt gpu_startup(struct sys_window *window) -{ /* Initialize handles pool */ G.handle_entries_mutex = sys_mutex_alloc(); G.handle_entries_arena = arena_alloc(GIGABYTE(64)); @@ -1032,99 +1026,6 @@ void gpu_dispatch(struct gpu_handle gpu_dispatch_state, struct gpu_dispatch_para { (UNUSED)gpu_dispatch_state; (UNUSED)params; - - struct pipeline_scope *pipeline_scope = pipeline_scope_begin(); - - /* Texture pass */ - { - struct pipeline *pipeline = dx12_get_pipeline(pipeline_scope, LIT("shaders/texture.hlsl")); - - } - - pipeline_scope_end(pipeline_scope); - -#if 0 - __prof; - struct sprite_scope *sprite_scope = sprite_scope_begin(); - struct dx11_dispatch_state *state = (struct dx11_dispatch_state *)gpu_dispatch_state.v; - - struct rect viewport = params.draw_target_viewport; - - /* Set viewport */ - D3D11_VIEWPORT d3d11_viewport = ZI; - d3d11_viewport.Width = viewport.width; - d3d11_viewport.Height = viewport.height; - d3d11_viewport.MinDepth = 0.0f; - d3d11_viewport.MaxDepth = 1.0f; - d3d11_viewport.TopLeftX = viewport.x; - d3d11_viewport.TopLeftY = viewport.y; - ID3D11DeviceContext_RSSetViewports(G.devcon, 1, &d3d11_viewport); - - struct dx12_buffer *final_tex = (struct dx12_buffer *)params.draw_target.v; - struct v2i32 final_tex_size = final_tex->size; - - /* Texture pass */ - { - __profscope(Texture pass); - struct dx11_shader *shader = &G.shaders[DX11_SHADER_KIND_TEXTURE]; - if (shader->valid) { - struct dx12_buffer *texture = NULL; - if (cmd->texture.texture.v) { - /* Load texture if handle is set */ - texture = (struct dx12_buffer *)cmd->texture.texture.v; - } else if (cmd->texture.sprite.hash) { - /* Otherwise load sprite */ - struct sprite_texture *sprite_texture = sprite_texture_from_tag_async(sprite_scope, cmd->texture.sprite); - if (sprite_texture->loaded) { - texture = (struct dx12_buffer *)sprite_texture->texture.v; - } - } - - if (texture && texture->srv) { - struct dx11_buffer *instance_buffer = list->buffers.texture.instance_buffer; - u32 instance_offset = cmd->texture.instance_offset; - u32 instance_count = cmd->texture.instance_count; - - /* Bind shader */ - ID3D11DeviceContext_VSSetShader(G.devcon, shader->vs, 0, 0); - ID3D11DeviceContext_PSSetShader(G.devcon, shader->ps, 0, 0); - - /* Fill & bind constant buffer */ - { - struct dx11_texture_uniform *uniform = dx11_buffer_push(constant_buffer, sizeof(struct dx11_texture_uniform)); - uniform->vp = vp_matrix; - uniform->instance_offset = instance_offset; - dx11_buffer_submit(constant_buffer); - } - ID3D11DeviceContext_VSSetConstantBuffers(G.devcon, 0, 1, &constant_buffer->gpu_buffer); - ID3D11DeviceContext_PSSetConstantBuffers(G.devcon, 0, 1, &constant_buffer->gpu_buffer); - - /* Bind dummy vertex buffer */ - u32 zero = 0; - ID3D11DeviceContext_IASetVertexBuffers(G.devcon, 0, 1, &G.dummy_vertex_buffer->gpu_buffer, &zero, &zero); - ID3D11DeviceContext_IASetIndexBuffer(G.devcon, G.quad_index_buffer->gpu_buffer, DXGI_FORMAT_R16_UINT, zero); - - /* Bind SRVs */ - ID3D11ShaderResourceView *srvs[] = { instance_buffer->srv, texture->srv }; - ID3D11DeviceContext_VSSetShaderResources(G.devcon, 0, ARRAY_COUNT(srvs), srvs); - ID3D11DeviceContext_PSSetShaderResources(G.devcon, 0, ARRAY_COUNT(srvs), srvs); - - /* Bind RTVs */ - ID3D11RenderTargetView *rtvs[] = { final_tex->rtv }; - ID3D11DeviceContext_OMSetRenderTargets(G.devcon, ARRAY_COUNT(rtvs), rtvs, NULL); - - /* Draw */ - ID3D11DeviceContext_IASetPrimitiveTopology(G.devcon, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - ID3D11DeviceContext_DrawIndexedInstanced(G.devcon, 6, instance_count, 0, 0, 0); - - /* Unbind */ - dx11_unbind(DX11_UNBIND_VS | DX11_UNBIND_PS | DX11_UNBIND_CBUFF | DX11_UNBIND_VBUFF | DX11_UNBIND_IBUFF | DX11_UNBIND_SRV | DX11_UNBIND_RTV); - } - } - } - - sprite_scope_end(sprite_scope); -#endif } /* ========================== *