tests: Add a test for sampling from nonzero mipmap levels.

This commit is contained in:
Zebediah Figura 2023-04-30 19:27:58 -05:00 committed by Alexandre Julliard
parent e3eb4fc5eb
commit 4ec60707e2
Notes: Alexandre Julliard 2023-05-08 22:34:30 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/191
8 changed files with 54 additions and 3 deletions

View File

@ -157,6 +157,7 @@ vkd3d_shader_tests = \
tests/register-reservations.shader_test \
tests/return.shader_test \
tests/round.shader_test \
tests/sample-level.shader_test \
tests/sampler.shader_test \
tests/sampler-offset.shader_test \
tests/saturate.shader_test \

View File

@ -0,0 +1,36 @@
[require]
shader model >= 3.0
[sampler 0]
filter linear linear linear
address clamp clamp clamp
[texture 0]
size (2, 2)
levels 2
1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0
1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0
0.0 0.0 1.0 0.0
[pixel shader todo]
sampler s;
Texture2D t;
uniform float level;
float4 main() : sv_target
{
return t.SampleLevel(s, float2(0.5, 0.5), level);
}
[test]
uniform 0 float4 0.0 0.0 0.0 0.0
todo draw quad
probe all rgba (1.0, 0.0, 1.0, 0.0)
uniform 0 float4 0.5 0.0 0.0 0.0
todo draw quad
probe all rgba (0.5, 0.0, 1.0, 0.0)
uniform 0 float4 1.0 0.0 0.0 0.0
todo draw quad
probe all rgba (0.0, 0.0, 1.0, 0.0)

View File

@ -116,6 +116,7 @@ static void parse_require_directive(struct shader_runner *runner, const char *li
static const char *const model_strings[] =
{
[SHADER_MODEL_2_0] = "2.0",
[SHADER_MODEL_3_0] = "3.0",
[SHADER_MODEL_4_0] = "4.0",
[SHADER_MODEL_4_1] = "4.1",
[SHADER_MODEL_5_0] = "5.0",
@ -747,6 +748,7 @@ static void compile_shader(struct shader_runner *runner, const char *source, siz
static const char *const shader_models[] =
{
[SHADER_MODEL_2_0] = "4_0",
[SHADER_MODEL_3_0] = "4_0",
[SHADER_MODEL_4_0] = "4_0",
[SHADER_MODEL_4_1] = "4_1",
[SHADER_MODEL_5_0] = "5_0",

View File

@ -31,6 +31,7 @@
enum shader_model
{
SHADER_MODEL_2_0,
SHADER_MODEL_3_0,
SHADER_MODEL_4_0,
SHADER_MODEL_4_1,
SHADER_MODEL_5_0,

View File

@ -80,6 +80,7 @@ static ID3D10Blob *compile_shader(const char *source, const char *type, enum sha
static const char *const shader_models[] =
{
[SHADER_MODEL_2_0] = "4_0",
[SHADER_MODEL_3_0] = "4_0",
[SHADER_MODEL_4_0] = "4_0",
[SHADER_MODEL_4_1] = "4_1",
[SHADER_MODEL_5_0] = "5_0",

View File

@ -65,6 +65,7 @@ static ID3D10Blob *compile_shader(const struct d3d12_shader_runner *runner, cons
static const char *const shader_models[] =
{
[SHADER_MODEL_2_0] = "4_0",
[SHADER_MODEL_3_0] = "4_0",
[SHADER_MODEL_4_0] = "4_0",
[SHADER_MODEL_4_1] = "4_1",
[SHADER_MODEL_5_0] = "5_0",

View File

@ -56,11 +56,19 @@ static struct d3d9_shader_runner *d3d9_shader_runner(struct shader_runner *r)
static IDirect3D9 *(WINAPI *pDirect3DCreate9)(UINT sdk_version);
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] = "2_0",
[SHADER_MODEL_3_0] = "3_0",
};
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)
@ -325,10 +333,10 @@ static bool d3d9_runner_draw(struct shader_runner *r,
unsigned int i, j;
HRESULT hr;
if (!(vs_code = compile_shader(runner->r.vs_source, "vs_2_0")))
if (!(vs_code = compile_shader(runner->r.vs_source, "vs", runner->r.minimum_shader_model)))
return false;
if (!(ps_code = compile_shader(runner->r.ps_source, "ps_2_0")))
if (!(ps_code = compile_shader(runner->r.ps_source, "ps", runner->r.minimum_shader_model)))
{
ID3D10Blob_Release(vs_code);
return false;

View File

@ -364,6 +364,7 @@ static bool compile_shader(const struct vulkan_shader_runner *runner, const char
static const char *const shader_models[] =
{
[SHADER_MODEL_2_0] = "4_0",
[SHADER_MODEL_3_0] = "4_0",
[SHADER_MODEL_4_0] = "4_0",
[SHADER_MODEL_4_1] = "4_1",
[SHADER_MODEL_5_0] = "5_0",