From 4eb4c9bba97d659eb199cf41fb607d02caf6c748 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 30 Jun 2023 17:13:38 -0400 Subject: [PATCH] d3d10umd: use cso_context to set vertex buffers and elements should be no functional changes Part-of: --- src/gallium/frontends/d3d10umd/Device.cpp | 2 ++ src/gallium/frontends/d3d10umd/Draw.cpp | 12 ++++++++++ .../frontends/d3d10umd/InputAssembly.cpp | 23 +++++++++---------- src/gallium/frontends/d3d10umd/State.h | 7 ++++-- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/gallium/frontends/d3d10umd/Device.cpp b/src/gallium/frontends/d3d10umd/Device.cpp index 96267f8e5d6..9d06dca3025 100644 --- a/src/gallium/frontends/d3d10umd/Device.cpp +++ b/src/gallium/frontends/d3d10umd/Device.cpp @@ -132,6 +132,7 @@ CreateDevice(D3D10DDI_HADAPTER hAdapter, // IN struct pipe_screen *screen = pAdapter->screen; struct pipe_context *pipe = screen->context_create(screen, NULL, 0); pDevice->pipe = pipe; + pDevice->cso = cso_create_context(pipe, CSO_NO_VBUF); pDevice->empty_vs = CreateEmptyShader(pDevice, PIPE_SHADER_VERTEX); pDevice->empty_fs = CreateEmptyShader(pDevice, PIPE_SHADER_FRAGMENT); @@ -334,6 +335,7 @@ DestroyDevice(D3D10DDI_HDEVICE hDevice) // IN pipe->bind_fs_state(pipe, NULL); pipe->bind_vs_state(pipe, NULL); + cso_destroy_context(pDevice->cso); DeleteEmptyShader(pDevice, PIPE_SHADER_FRAGMENT, pDevice->empty_fs); DeleteEmptyShader(pDevice, PIPE_SHADER_VERTEX, pDevice->empty_vs); diff --git a/src/gallium/frontends/d3d10umd/Draw.cpp b/src/gallium/frontends/d3d10umd/Draw.cpp index 012bb522ec7..1b7db2eb788 100644 --- a/src/gallium/frontends/d3d10umd/Draw.cpp +++ b/src/gallium/frontends/d3d10umd/Draw.cpp @@ -52,6 +52,17 @@ ClampedUAdd(unsigned a, } +static void +update_velems(Device *pDevice) +{ + if (!pDevice->velems_changed) + return; + + cso_set_vertex_elements(pDevice->cso, &pDevice->element_layout->velems); + + pDevice->velems_changed = false; +} + /* * We have to resolve the stream output state for empty geometry shaders. * In particular we've remapped the output indices when translating the @@ -85,6 +96,7 @@ ResolveState(Device *pDevice) } pipe->bind_gs_state(pipe, gs->handle); } + update_velems(pDevice); } diff --git a/src/gallium/frontends/d3d10umd/InputAssembly.cpp b/src/gallium/frontends/d3d10umd/InputAssembly.cpp index 9dc2e6452c3..dd4ebfcae80 100644 --- a/src/gallium/frontends/d3d10umd/InputAssembly.cpp +++ b/src/gallium/frontends/d3d10umd/InputAssembly.cpp @@ -178,7 +178,8 @@ IaSetVertexBuffers(D3D10DDI_HDEVICE hDevice, /* Resubmit old and new vertex buffers. */ - pipe->set_vertex_buffers(pipe, PIPE_MAX_ATTRIBS, 0, false, pDevice->vertex_buffers); + cso_set_vertex_buffers(pDevice->cso, PIPE_MAX_ATTRIBS, 0, false, pDevice->vertex_buffers); + pDevice->velems_changed = true; } @@ -269,10 +270,9 @@ CreateElementLayout( { LOG_ENTRYPOINT(); - struct pipe_context *pipe = CastPipeContext(hDevice); ElementLayout *pElementLayout = CastElementLayout(hElementLayout); - struct pipe_vertex_element elements[PIPE_MAX_ATTRIBS]; + struct cso_velems_state elements; memset(elements, 0, sizeof elements); unsigned num_elements = pCreateElementLayout->NumElements; @@ -281,7 +281,7 @@ CreateElementLayout( const D3D10DDIARG_INPUT_ELEMENT_DESC* pVertexElement = &pCreateElementLayout->pVertexElements[i]; struct pipe_vertex_element *ve = - &elements[pVertexElement->InputRegister]; + &elements.velems[pVertexElement->InputRegister]; ve->src_offset = pVertexElement->AlignedByteOffset; ve->vertex_buffer_index = pVertexElement->InputSlot; @@ -312,8 +312,8 @@ CreateElementLayout( DebugPrintf("%s: gap\n", __func__); } - pElementLayout->handle = - pipe->create_vertex_elements_state(pipe, max_elements, elements); + elements.count = max_elements; + pElementLayout->velems = mem_dup(elements, sizeof(elements)); } @@ -338,7 +338,8 @@ DestroyElementLayout(D3D10DDI_HDEVICE hDevice, // IN struct pipe_context *pipe = CastPipeContext(hDevice); ElementLayout *pElementLayout = CastElementLayout(hElementLayout); - pipe->delete_vertex_elements_state(pipe, pElementLayout->handle);} + free(pElementLayout->velems); +} /* @@ -358,10 +359,8 @@ IaSetInputLayout(D3D10DDI_HDEVICE hDevice, // IN { LOG_ENTRYPOINT(); - struct pipe_context *pipe = CastPipeContext(hDevice); - void *state = CastPipeInputLayout(hInputLayout); + Device *pDevice = CastDevice(hDevice); + pDevice->element_layout = CastElementLayout(hInputLayout); + pDevice->velems_changed = true; - pipe->bind_vertex_elements_state(pipe, state); } - - diff --git a/src/gallium/frontends/d3d10umd/State.h b/src/gallium/frontends/d3d10umd/State.h index 3b52c4543b0..753046e229e 100644 --- a/src/gallium/frontends/d3d10umd/State.h +++ b/src/gallium/frontends/d3d10umd/State.h @@ -33,7 +33,7 @@ #include "DriverIncludes.h" #include "util/u_hash_table.h" - +#include "cso_cache/cso_context.h" #define SUPPORT_MSAA 0 #define SUPPORT_D3D10_1 0 @@ -67,6 +67,7 @@ struct Device { struct pipe_context *pipe; + struct cso_context *cso; struct pipe_framebuffer_state fb; struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS]; struct pipe_resource *index_buffer; @@ -102,6 +103,8 @@ struct Device Query *pPredicate; BOOL PredicateValue; + + BOOL velems_changed; }; @@ -322,7 +325,7 @@ CastPipeShader(D3D10DDI_HSHADER hShader) struct ElementLayout { - void *handle; + struct cso_velems_state *velems; };