[PATCH vkd3d v2 4/7] tests: Move d3d12-specific members of struct texture to a new d3d12_texture structure.

Zebediah Figura zfigura at codeweavers.com
Fri Jan 14 17:33:05 CST 2022


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 tests/shader_runner.h       |  5 -----
 tests/shader_runner_d3d12.c | 31 ++++++++++++++++++++++++-------
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/tests/shader_runner.h b/tests/shader_runner.h
index 3bc67feee..543b648a7 100644
--- a/tests/shader_runner.h
+++ b/tests/shader_runner.h
@@ -54,11 +54,6 @@ struct texture_params
 struct texture
 {
     unsigned int slot;
-
-    D3D12_DESCRIPTOR_RANGE descriptor_range;
-    ID3D12DescriptorHeap *heap;
-    ID3D12Resource *resource;
-    unsigned int root_index;
 };
 
 struct shader_context
diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c
index 4a793c26c..e124f8aa0 100644
--- a/tests/shader_runner_d3d12.c
+++ b/tests/shader_runner_d3d12.c
@@ -23,6 +23,21 @@
 #include "d3d12_crosstest.h"
 #include "shader_runner.h"
 
+struct d3d12_texture
+{
+    struct texture t;
+
+    D3D12_DESCRIPTOR_RANGE descriptor_range;
+    ID3D12DescriptorHeap *heap;
+    ID3D12Resource *resource;
+    unsigned int root_index;
+};
+
+static struct d3d12_texture *d3d12_texture(struct texture *t)
+{
+    return CONTAINING_RECORD(t, struct d3d12_texture, t);
+}
+
 struct d3d12_shader_context
 {
     struct shader_context c;
@@ -57,11 +72,11 @@ static struct texture *d3d12_runner_create_texture(struct shader_context *c, con
     struct test_context *test_context = &context->test_context;
     ID3D12Device *device = test_context->device;
     D3D12_SUBRESOURCE_DATA resource_data;
-    struct texture *texture;
+    struct d3d12_texture *texture;
 
     texture = calloc(1, sizeof(*texture));
 
-    texture->slot = params->slot;
+    texture->t.slot = params->slot;
 
     texture->heap = create_gpu_descriptor_heap(device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 1);
     texture->resource = create_default_texture(device, params->width, params->height,
@@ -75,11 +90,13 @@ static struct texture *d3d12_runner_create_texture(struct shader_context *c, con
     ID3D12Device_CreateShaderResourceView(device, texture->resource,
             NULL, get_cpu_descriptor_handle(test_context, texture->heap, 0));
 
-    return texture;
+    return &texture->t;
 }
 
-static void d3d12_runner_destroy_texture(struct shader_context *c, struct texture *texture)
+static void d3d12_runner_destroy_texture(struct shader_context *c, struct texture *t)
 {
+    struct d3d12_texture *texture = d3d12_texture(t);
+
     ID3D12DescriptorHeap_Release(texture->heap);
     ID3D12Resource_Release(texture->resource);
     free(texture);
@@ -122,7 +139,7 @@ static void d3d12_runner_draw_quad(struct shader_context *c)
 
     for (i = 0; i < context->c.texture_count; ++i)
     {
-        struct texture *texture = context->c.textures[i];
+        struct d3d12_texture *texture = d3d12_texture(context->c.textures[i]);
         D3D12_DESCRIPTOR_RANGE *range;
 
         range = &texture->descriptor_range;
@@ -136,7 +153,7 @@ static void d3d12_runner_draw_quad(struct shader_context *c)
 
         range->RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV;
         range->NumDescriptors = 1;
-        range->BaseShaderRegister = texture->slot;
+        range->BaseShaderRegister = texture->t.slot;
         range->RegisterSpace = 0;
         range->OffsetInDescriptorsFromTableStart = 0;
     }
@@ -177,7 +194,7 @@ static void d3d12_runner_draw_quad(struct shader_context *c)
                 context->c.uniform_count, context->c.uniforms, 0);
     for (i = 0; i < context->c.texture_count; ++i)
     {
-        struct texture *texture = context->c.textures[i];
+        struct d3d12_texture *texture = d3d12_texture(context->c.textures[i]);
 
         ID3D12GraphicsCommandList_SetGraphicsRootDescriptorTable(command_list, texture->root_index,
                 get_gpu_descriptor_handle(test_context, texture->heap, 0));
-- 
2.34.1




More information about the wine-devel mailing list