mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
tests: Move HLSL shader compilation to a new d3d12 shader runner backend.
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:
committed by
Alexandre Julliard
parent
63622a92e8
commit
85d61f0c64
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2020 Zebediah Figura for CodeWeavers
|
||||
* Copyright 2020-2021 Zebediah Figura for CodeWeavers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -43,6 +43,7 @@
|
||||
*/
|
||||
|
||||
#include "d3d12_crosstest.h"
|
||||
#include "shader_runner.h"
|
||||
#include <errno.h>
|
||||
|
||||
static void VKD3D_NORETURN VKD3D_PRINTF_FUNC(1, 2) fatal_error(const char *format, ...)
|
||||
@@ -115,16 +116,10 @@ struct texture
|
||||
unsigned int root_index;
|
||||
};
|
||||
|
||||
enum shader_model
|
||||
{
|
||||
SHADER_MODEL_4_0 = 0,
|
||||
SHADER_MODEL_4_1,
|
||||
SHADER_MODEL_5_0,
|
||||
SHADER_MODEL_5_1,
|
||||
};
|
||||
|
||||
struct shader_context
|
||||
{
|
||||
const struct shader_runner_ops *ops;
|
||||
|
||||
struct test_context c;
|
||||
enum shader_model minimum_shader_model;
|
||||
|
||||
@@ -140,22 +135,6 @@ struct shader_context
|
||||
size_t sampler_count;
|
||||
};
|
||||
|
||||
static ID3D10Blob *compile_shader(const char *source, const char *target)
|
||||
{
|
||||
ID3D10Blob *blob = NULL, *errors = NULL;
|
||||
HRESULT hr;
|
||||
|
||||
hr = D3DCompile(source, strlen(source), NULL, NULL, NULL, "main", target, 0, 0, &blob, &errors);
|
||||
ok(hr == S_OK, "Failed to compile shader, hr %#x.\n", hr);
|
||||
if (errors)
|
||||
{
|
||||
if (vkd3d_test_state.debug_level)
|
||||
trace("%s\n", (char *)ID3D10Blob_GetBufferPointer(errors));
|
||||
ID3D10Blob_Release(errors);
|
||||
}
|
||||
return blob;
|
||||
}
|
||||
|
||||
static void free_texture(struct texture *texture)
|
||||
{
|
||||
ID3D12DescriptorHeap_Release(texture->heap);
|
||||
@@ -643,7 +622,7 @@ static struct texture *get_texture(struct shader_context *context, unsigned int
|
||||
return NULL;
|
||||
}
|
||||
|
||||
START_TEST(shader_runner)
|
||||
void run_shader_tests(int argc, char **argv, const struct shader_runner_ops *ops)
|
||||
{
|
||||
static const struct test_context_desc desc =
|
||||
{
|
||||
@@ -689,6 +668,7 @@ START_TEST(shader_runner)
|
||||
}
|
||||
|
||||
memset(&context, 0, sizeof(context));
|
||||
context.ops = ops;
|
||||
init_test_context(&context.c, &desc);
|
||||
|
||||
for (;;)
|
||||
@@ -709,20 +689,10 @@ START_TEST(shader_runner)
|
||||
break;
|
||||
|
||||
case STATE_SHADER_PIXEL:
|
||||
{
|
||||
static const char *const shader_models[] =
|
||||
{
|
||||
[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 (!(context.ps_code = compile_shader(shader_source, shader_models[context.minimum_shader_model])))
|
||||
if (!(context.ps_code = context.ops->compile_shader(shader_source, context.minimum_shader_model)))
|
||||
return;
|
||||
shader_source_len = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_SHADER_INVALID_PIXEL:
|
||||
{
|
||||
@@ -926,3 +896,8 @@ START_TEST(shader_runner)
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
START_TEST(shader_runner)
|
||||
{
|
||||
run_shader_tests_d3d12(argc, argv);
|
||||
}
|
||||
|
37
tests/shader_runner.h
Normal file
37
tests/shader_runner.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2021 Zebediah Figura for CodeWeavers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "vkd3d_windows.h"
|
||||
#include "vkd3d_d3dcommon.h"
|
||||
|
||||
enum shader_model
|
||||
{
|
||||
SHADER_MODEL_4_0 = 0,
|
||||
SHADER_MODEL_4_1,
|
||||
SHADER_MODEL_5_0,
|
||||
SHADER_MODEL_5_1,
|
||||
};
|
||||
|
||||
struct shader_runner_ops
|
||||
{
|
||||
ID3D10Blob *(*compile_shader)(const char *source, enum shader_model minimum_shader_model);
|
||||
};
|
||||
|
||||
void run_shader_tests(int argc, char **argv, const struct shader_runner_ops *ops);
|
||||
|
||||
void run_shader_tests_d3d12(int argc, char **argv);
|
66
tests/shader_runner_d3d12.c
Normal file
66
tests/shader_runner_d3d12.c
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2020-2021 Zebediah Figura for CodeWeavers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifdef __MINGW32__
|
||||
# define _HRESULT_DEFINED
|
||||
typedef int HRESULT;
|
||||
#endif
|
||||
|
||||
#define COBJMACROS
|
||||
#define CONST_VTABLE
|
||||
#define VKD3D_TEST_NO_DEFS
|
||||
#include "vkd3d_windows.h"
|
||||
#include "vkd3d_d3dcommon.h"
|
||||
#include "vkd3d_d3dcompiler.h"
|
||||
#include "vkd3d_test.h"
|
||||
#include "shader_runner.h"
|
||||
|
||||
static ID3D10Blob *d3d12_runner_compile_shader(const char *source, enum shader_model shader_model)
|
||||
{
|
||||
ID3D10Blob *blob = NULL, *errors = NULL;
|
||||
HRESULT hr;
|
||||
|
||||
static const char *const shader_models[] =
|
||||
{
|
||||
[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",
|
||||
};
|
||||
|
||||
hr = D3DCompile(source, strlen(source), NULL, NULL, NULL, "main",
|
||||
shader_models[shader_model], 0, 0, &blob, &errors);
|
||||
ok(hr == S_OK, "Failed to compile shader, hr %#x.\n", hr);
|
||||
if (errors)
|
||||
{
|
||||
if (vkd3d_test_state.debug_level)
|
||||
trace("%s\n", (char *)ID3D10Blob_GetBufferPointer(errors));
|
||||
ID3D10Blob_Release(errors);
|
||||
}
|
||||
return blob;
|
||||
}
|
||||
|
||||
static const struct shader_runner_ops d3d12_runner_ops =
|
||||
{
|
||||
.compile_shader = d3d12_runner_compile_shader,
|
||||
};
|
||||
|
||||
void run_shader_tests_d3d12(int argc, char **argv)
|
||||
{
|
||||
run_shader_tests(argc, argv, &d3d12_runner_ops);
|
||||
}
|
Reference in New Issue
Block a user