For compatibility with shader models before 4.0.
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
tests/shader_runner.c | 71 +++++++++++++++++++++++++++++--------------
1 file changed, 49 insertions(+), 22 deletions(-)
diff --git a/tests/shader_runner.c b/tests/shader_runner.c
index d3d131164..0ad2d56c7 100644
--- a/tests/shader_runner.c
+++ b/tests/shader_runner.c
@@ -314,6 +314,24 @@ static void parse_input_layout_directive(struct shader_runner *runner, const cha
element->index = 0;
}
+static void set_resource(struct shader_runner *runner, struct resource *resource)
+{
+ size_t i;
+
+ for (i = 0; i < runner->resource_count; ++i)
+ {
+ if (runner->resources[i]->slot == resource->slot && runner->resources[i]->type == resource->type)
+ {
+ runner->ops->destroy_resource(runner, runner->resources[i]);
+ runner->resources[i] = resource;
+ return;
+ }
+ }
+
+ runner->resources = realloc(runner->resources, (runner->resource_count + 1) * sizeof(*runner->resources));
+ runner->resources[runner->resource_count++] = resource;
+}
+
static void set_uniforms(struct shader_runner *runner, size_t offset, size_t count, const void *uniforms)
{
runner->uniform_count = align(max(runner->uniform_count, offset + count), 4);
@@ -326,17 +344,44 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
{
if (match_string(line, "draw quad", &line))
{
+ struct resource_params params;
+ struct input_element *element;
+
+ static const struct vec2 quad[] =
+ {
+ {-1.0f, -1.0f},
+ {-1.0f, 1.0f},
+ { 1.0f, -1.0f},
+ { 1.0f, 1.0f},
+ };
+
static const char vs_source[] =
- "void main(uint id : SV_VertexID, out float4 position : SV_Position)\n"
+ "void main(inout float4 position : sv_position)\n"
"{\n"
- " float2 coords = float2((id << 1) & 2, id & 2);\n"
- " position = float4(coords * float2(2, -2) + float2(-1, 1), 0, 1);\n"
"}";
+ vkd3d_array_reserve((void **)&runner->input_elements, &runner->input_element_capacity,
+ 1, sizeof(*runner->input_elements));
+ element = &runner->input_elements[0];
+ element->name = strdup("sv_position");
+ element->slot = 0;
+ element->format = DXGI_FORMAT_R32G32_FLOAT;
+ element->texel_size = sizeof(*quad);
+ element->index = 0;
+ runner->input_element_count = 1;
+
+ memset(¶ms, 0, sizeof(params));
+ params.slot = 0;
+ params.type = RESOURCE_TYPE_VERTEX_BUFFER;
+ params.data = malloc(sizeof(quad));
+ memcpy(params.data, quad, sizeof(quad));
+ params.data_size = sizeof(quad);
+ set_resource(runner, runner->ops->create_resource(runner, ¶ms));
+
if (!runner->vs_source)
runner->vs_source = strdup(vs_source);
- runner->ops->draw(runner, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST, 3);
+ runner->ops->draw(runner, D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, 4);
}
else if (match_string(line, "draw", &line))
{
@@ -482,24 +527,6 @@ static struct sampler *get_sampler(struct shader_runner *runner, unsigned int sl
return NULL;
}
-static void set_resource(struct shader_runner *runner, struct resource *resource)
-{
- size_t i;
-
- for (i = 0; i < runner->resource_count; ++i)
- {
- if (runner->resources[i]->slot == resource->slot && runner->resources[i]->type == resource->type)
- {
- runner->ops->destroy_resource(runner, runner->resources[i]);
- runner->resources[i] = resource;
- return;
- }
- }
-
- runner->resources = realloc(runner->resources, (runner->resource_count + 1) * sizeof(*runner->resources));
- runner->resources[runner->resource_count++] = resource;
-}
-
unsigned int get_vb_stride(const struct shader_runner *runner, unsigned int slot)
{
unsigned int stride = 0;
--
2.35.1