mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
tests: Specify the default vertex shader in the shader runner frontend.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
52223250d7
commit
16b383aef5
@ -290,6 +290,16 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
|
||||
{
|
||||
if (match_string(line, "draw quad", &line))
|
||||
{
|
||||
static const char vs_source[] =
|
||||
"void main(uint id : SV_VertexID, out 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"
|
||||
"}";
|
||||
|
||||
if (!runner->vs_source)
|
||||
runner->vs_source = strdup(vs_source);
|
||||
|
||||
runner->ops->draw_quad(runner);
|
||||
}
|
||||
else if (match_string(line, "probe all rgba", &line))
|
||||
|
@ -61,8 +61,6 @@ struct d3d11_shader_runner
|
||||
ID3D11Texture2D *rt;
|
||||
ID3D11RenderTargetView *rtv;
|
||||
ID3D11DeviceContext *immediate_context;
|
||||
|
||||
ID3D11VertexShader *vs;
|
||||
};
|
||||
|
||||
static struct d3d11_shader_runner *d3d11_shader_runner(struct shader_runner *r)
|
||||
@ -74,11 +72,22 @@ static bool enable_debug_layer;
|
||||
static bool use_warp_adapter;
|
||||
static unsigned int use_adapter_idx;
|
||||
|
||||
static ID3D10Blob *compile_shader(const char *source, const char *profile)
|
||||
static ID3D10Blob *compile_shader(const char *source, const char *type, enum shader_model shader_model)
|
||||
{
|
||||
ID3D10Blob *blob = NULL, *errors = NULL;
|
||||
char profile[7];
|
||||
HRESULT hr;
|
||||
|
||||
static const char *const shader_models[] =
|
||||
{
|
||||
[SHADER_MODEL_2_0] = "4_0",
|
||||
[SHADER_MODEL_4_0] = "4_0",
|
||||
[SHADER_MODEL_4_1] = "4_1",
|
||||
[SHADER_MODEL_5_0] = "5_0",
|
||||
[SHADER_MODEL_5_1] = "5_1",
|
||||
};
|
||||
|
||||
sprintf(profile, "%s_%s", type, shader_models[shader_model]);
|
||||
hr = D3DCompile(source, strlen(source), NULL, NULL, NULL, "main", profile, 0, 0, &blob, &errors);
|
||||
ok(hr == S_OK, "Failed to compile shader, hr %#lx.\n", hr);
|
||||
if (errors)
|
||||
@ -323,9 +332,6 @@ static void destroy_test_context(struct d3d11_shader_runner *runner)
|
||||
{
|
||||
ULONG ref;
|
||||
|
||||
if (runner->vs)
|
||||
ID3D11VertexShader_Release(runner->vs);
|
||||
|
||||
ID3D11DeviceContext_Release(runner->immediate_context);
|
||||
ID3D11RenderTargetView_Release(runner->rtv);
|
||||
ID3D11Texture2D_Release(runner->rt);
|
||||
@ -405,43 +411,28 @@ static void d3d11_runner_destroy_texture(struct shader_runner *r, struct texture
|
||||
|
||||
static void d3d11_runner_draw_quad(struct shader_runner *r)
|
||||
{
|
||||
static const char vs_source[] =
|
||||
"void main(uint id : SV_VertexID, out 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"
|
||||
"}";
|
||||
|
||||
struct d3d11_shader_runner *runner = d3d11_shader_runner(r);
|
||||
ID3D11Device *device = runner->device;
|
||||
ID3D10Blob *vs_code, *ps_code;
|
||||
ID3D11Buffer *cb = NULL;
|
||||
ID3D11VertexShader *vs;
|
||||
ID3D11PixelShader *ps;
|
||||
ID3D10Blob *ps_code;
|
||||
unsigned int i;
|
||||
HRESULT hr;
|
||||
|
||||
static const char *const ps_profiles[] =
|
||||
{
|
||||
[SHADER_MODEL_2_0] = "ps_4_0",
|
||||
[SHADER_MODEL_4_0] = "ps_4_0",
|
||||
[SHADER_MODEL_4_1] = "ps_4_1",
|
||||
[SHADER_MODEL_5_0] = "ps_5_0",
|
||||
[SHADER_MODEL_5_1] = "ps_5_1",
|
||||
};
|
||||
|
||||
if (!(ps_code = compile_shader(runner->r.ps_source, ps_profiles[runner->r.minimum_shader_model])))
|
||||
if (!(vs_code = compile_shader(runner->r.vs_source, "vs", runner->r.minimum_shader_model)))
|
||||
return;
|
||||
|
||||
if (!runner->vs)
|
||||
if (!(ps_code = compile_shader(runner->r.ps_source, "ps", runner->r.minimum_shader_model)))
|
||||
{
|
||||
ID3D10Blob *vs_code = compile_shader(runner->r.vs_source ? runner->r.vs_source : vs_source, "vs_4_0");
|
||||
|
||||
hr = ID3D11Device_CreateVertexShader(device, ID3D10Blob_GetBufferPointer(vs_code),
|
||||
ID3D10Blob_GetBufferSize(vs_code), NULL, &runner->vs);
|
||||
ok(hr == S_OK, "Failed to create vertex shader, hr %#lx.\n", hr);
|
||||
ID3D10Blob_Release(vs_code);
|
||||
return;
|
||||
}
|
||||
|
||||
hr = ID3D11Device_CreateVertexShader(device, ID3D10Blob_GetBufferPointer(vs_code),
|
||||
ID3D10Blob_GetBufferSize(vs_code), NULL, &vs);
|
||||
ok(hr == S_OK, "Failed to create vertex shader, hr %#lx.\n", hr);
|
||||
|
||||
hr = ID3D11Device_CreatePixelShader(device, ID3D10Blob_GetBufferPointer(ps_code),
|
||||
ID3D10Blob_GetBufferSize(ps_code), NULL, &ps);
|
||||
ok(hr == S_OK, "Failed to create pixel shader, hr %#lx.\n", hr);
|
||||
@ -482,12 +473,13 @@ static void d3d11_runner_draw_quad(struct shader_runner *r)
|
||||
}
|
||||
|
||||
ID3D11DeviceContext_IASetPrimitiveTopology(runner->immediate_context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
ID3D11DeviceContext_VSSetShader(runner->immediate_context, runner->vs, NULL, 0);
|
||||
ID3D11DeviceContext_VSSetShader(runner->immediate_context, vs, NULL, 0);
|
||||
ID3D11DeviceContext_PSSetShader(runner->immediate_context, ps, NULL, 0);
|
||||
|
||||
ID3D11DeviceContext_Draw(runner->immediate_context, 3, 0);
|
||||
|
||||
ID3D11PixelShader_Release(ps);
|
||||
ID3D11VertexShader_Release(vs);
|
||||
if (cb)
|
||||
ID3D11Buffer_Release(cb);
|
||||
}
|
||||
|
@ -133,8 +133,8 @@ static void d3d12_runner_draw_quad(struct shader_runner *r)
|
||||
ID3D12CommandQueue *queue = test_context->queue;
|
||||
D3D12_STATIC_SAMPLER_DESC static_samplers[1];
|
||||
ID3D12Device *device = test_context->device;
|
||||
ID3D10Blob *vs_code = NULL, *ps_code;
|
||||
static const float clear_color[4];
|
||||
ID3D10Blob *vs_code, *ps_code;
|
||||
D3D12_SHADER_BYTECODE vs, ps;
|
||||
unsigned int uniform_index;
|
||||
ID3D12PipelineState *pso;
|
||||
@ -144,7 +144,7 @@ static void d3d12_runner_draw_quad(struct shader_runner *r)
|
||||
if (!(ps_code = compile_shader(runner->r.ps_source, "ps", runner->r.minimum_shader_model)))
|
||||
return;
|
||||
|
||||
if (runner->r.vs_source && !(vs_code = compile_shader(runner->r.vs_source, "vs", runner->r.minimum_shader_model)))
|
||||
if (!(vs_code = compile_shader(runner->r.vs_source, "vs", runner->r.minimum_shader_model)))
|
||||
{
|
||||
ID3D10Blob_Release(ps_code);
|
||||
return;
|
||||
@ -209,17 +209,13 @@ static void d3d12_runner_draw_quad(struct shader_runner *r)
|
||||
hr = create_root_signature(device, &root_signature_desc, &test_context->root_signature);
|
||||
ok(hr == S_OK, "Failed to create root signature, hr %#x.\n", hr);
|
||||
|
||||
if (vs_code)
|
||||
{
|
||||
vs.pShaderBytecode = ID3D10Blob_GetBufferPointer(vs_code);
|
||||
vs.BytecodeLength = ID3D10Blob_GetBufferSize(vs_code);
|
||||
}
|
||||
vs.pShaderBytecode = ID3D10Blob_GetBufferPointer(vs_code);
|
||||
vs.BytecodeLength = ID3D10Blob_GetBufferSize(vs_code);
|
||||
ps.pShaderBytecode = ID3D10Blob_GetBufferPointer(ps_code);
|
||||
ps.BytecodeLength = ID3D10Blob_GetBufferSize(ps_code);
|
||||
pso = create_pipeline_state(device, test_context->root_signature,
|
||||
test_context->render_target_desc.Format, vs_code ? &vs : NULL, &ps, NULL);
|
||||
if (vs_code)
|
||||
ID3D10Blob_Release(vs_code);
|
||||
test_context->render_target_desc.Format, &vs, &ps, NULL);
|
||||
ID3D10Blob_Release(vs_code);
|
||||
ID3D10Blob_Release(ps_code);
|
||||
if (!pso)
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user