Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
cdeeffb9
Commit
cdeeffb9
authored
Jul 06, 2023
by
Nikolay Sivov
Committed by
Alexandre Julliard
Jul 11, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3dcompiler/tests: Add some tests for matrix packing order compile flags.
parent
4de67d87
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
122 additions
and
62 deletions
+122
-62
hlsl_d3d9.c
dlls/d3dcompiler_43/tests/hlsl_d3d9.c
+122
-62
No files found.
dlls/d3dcompiler_43/tests/hlsl_d3d9.c
View file @
cdeeffb9
...
...
@@ -99,13 +99,14 @@ static void delete_directory(const WCHAR *dir)
RemoveDirectoryW
(
path
);
}
#define compile_shader(a, b) compile_shader_(__LINE__, a, b)
static
ID3D10Blob
*
compile_shader_
(
unsigned
int
line
,
const
char
*
source
,
const
char
*
target
)
#define compile_shader(a, b, c) compile_shader_(__LINE__, a, b, c)
static
ID3D10Blob
*
compile_shader_
(
unsigned
int
line
,
const
char
*
source
,
const
char
*
target
,
unsigned
int
flags
)
{
ID3D10Blob
*
blob
=
NULL
,
*
errors
=
NULL
;
HRESULT
hr
;
hr
=
D3DCompile
(
source
,
strlen
(
source
),
NULL
,
NULL
,
NULL
,
"main"
,
target
,
0
,
0
,
&
blob
,
&
errors
);
hr
=
D3DCompile
(
source
,
strlen
(
source
),
NULL
,
NULL
,
NULL
,
"main"
,
target
,
flags
,
0
,
&
blob
,
&
errors
);
ok_
(
__FILE__
,
line
)(
hr
==
D3D_OK
,
"Failed to compile shader, hr %#lx.
\n
"
,
hr
);
if
(
errors
)
{
...
...
@@ -243,7 +244,7 @@ static void draw_quad_(unsigned int line, IDirect3DDevice9 *device, ID3D10Blob *
hr
=
IDirect3DDevice9_SetVertexDeclaration
(
device
,
vertex_declaration
);
ok_
(
__FILE__
,
line
)(
hr
==
D3D_OK
,
"Failed to set vertex declaration, hr %#lx.
\n
"
,
hr
);
vs_code
=
compile_shader
(
vs_source
,
"vs_2_0"
);
vs_code
=
compile_shader
(
vs_source
,
"vs_2_0"
,
0
);
hr
=
IDirect3DDevice9_CreateVertexShader
(
device
,
ID3D10Blob_GetBufferPointer
(
vs_code
),
&
vs
);
ok_
(
__FILE__
,
line
)(
hr
==
D3D_OK
,
"Failed to create vertex shader, hr %#lx.
\n
"
,
hr
);
...
...
@@ -454,7 +455,7 @@ static void test_swizzle(void)
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
tests
);
++
i
)
{
ps_code
=
compile_shader
(
tests
[
i
].
source
,
"ps_2_0"
);
ps_code
=
compile_shader
(
tests
[
i
].
source
,
"ps_2_0"
,
0
);
if
(
i
==
0
)
{
hr
=
pD3DXGetShaderConstantTable
(
ID3D10Blob_GetBufferPointer
(
ps_code
),
&
constants
);
...
...
@@ -498,7 +499,7 @@ static void test_math(void)
return
;
device
=
test_context
.
device
;
ps_code
=
compile_shader
(
ps_source
,
"ps_2_0"
);
ps_code
=
compile_shader
(
ps_source
,
"ps_2_0"
,
0
);
hr
=
pD3DXGetShaderConstantTable
(
ID3D10Blob_GetBufferPointer
(
ps_code
),
&
constants
);
ok
(
hr
==
D3D_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID3DXConstantTable_SetFloat
(
constants
,
device
,
"$u"
,
2
.
5
f
);
...
...
@@ -553,7 +554,7 @@ static void test_conditionals(void)
return
;
device
=
test_context
.
device
;
ps_code
=
compile_shader
(
ps_if_source
,
"ps_2_0"
);
ps_code
=
compile_shader
(
ps_if_source
,
"ps_2_0"
,
0
);
draw_quad
(
device
,
ps_code
);
init_readback
(
device
,
&
rb
);
...
...
@@ -574,7 +575,7 @@ static void test_conditionals(void)
release_readback
(
&
rb
);
ID3D10Blob_Release
(
ps_code
);
todo_wine
ps_code
=
compile_shader
(
ps_ternary_source
,
"ps_2_0"
);
todo_wine
ps_code
=
compile_shader
(
ps_ternary_source
,
"ps_2_0"
,
0
);
if
(
ps_code
)
{
draw_quad
(
device
,
ps_code
);
...
...
@@ -636,7 +637,7 @@ static void test_float_vectors(void)
return
;
device
=
test_context
.
device
;
ps_code
=
compile_shader
(
ps_indexing_source
,
"ps_2_0"
);
ps_code
=
compile_shader
(
ps_indexing_source
,
"ps_2_0"
,
0
);
if
(
ps_code
)
{
draw_quad
(
device
,
ps_code
);
...
...
@@ -648,7 +649,7 @@ static void test_float_vectors(void)
ID3D10Blob_Release
(
ps_code
);
}
ps_code
=
compile_shader
(
ps_uniform_indexing_source
,
"ps_2_0"
);
ps_code
=
compile_shader
(
ps_uniform_indexing_source
,
"ps_2_0"
,
0
);
if
(
ps_code
)
{
hr
=
pD3DXGetShaderConstantTable
(
ID3D10Blob_GetBufferPointer
(
ps_code
),
&
constants
);
...
...
@@ -691,7 +692,7 @@ static void test_trig(void)
return
;
device
=
test_context
.
device
;
ps_code
=
compile_shader
(
ps_source
,
"ps_2_0"
);
ps_code
=
compile_shader
(
ps_source
,
"ps_2_0"
,
0
);
if
(
ps_code
)
{
draw_quad
(
device
,
ps_code
);
...
...
@@ -730,7 +731,7 @@ static void test_comma(void)
if
(
!
init_test_context
(
&
test_context
))
return
;
ps_code
=
compile_shader
(
ps_source
,
"ps_2_0"
);
ps_code
=
compile_shader
(
ps_source
,
"ps_2_0"
,
0
);
draw_quad
(
test_context
.
device
,
ps_code
);
v
=
get_color_vec4
(
test_context
.
device
,
0
,
0
);
...
...
@@ -764,7 +765,7 @@ static void test_return(void)
if
(
!
init_test_context
(
&
test_context
))
return
;
ps_code
=
compile_shader
(
void_source
,
"ps_2_0"
);
ps_code
=
compile_shader
(
void_source
,
"ps_2_0"
,
0
);
draw_quad
(
test_context
.
device
,
ps_code
);
v
=
get_color_vec4
(
test_context
.
device
,
0
,
0
);
...
...
@@ -773,7 +774,7 @@ static void test_return(void)
ID3D10Blob_Release
(
ps_code
);
ps_code
=
compile_shader
(
implicit_conversion_source
,
"ps_2_0"
);
ps_code
=
compile_shader
(
implicit_conversion_source
,
"ps_2_0"
,
0
);
if
(
ps_code
)
{
draw_quad
(
test_context
.
device
,
ps_code
);
...
...
@@ -809,7 +810,7 @@ static void test_array_dimensions(void)
if
(
!
init_test_context
(
&
test_context
))
return
;
todo_wine
ps_code
=
compile_shader
(
shader
,
"ps_2_0"
);
todo_wine
ps_code
=
compile_shader
(
shader
,
"ps_2_0"
,
0
);
if
(
ps_code
)
{
draw_quad
(
test_context
.
device
,
ps_code
);
...
...
@@ -826,11 +827,9 @@ static void test_array_dimensions(void)
static
void
test_majority
(
void
)
{
static
const
D3DXMATRIX
matrix
=
{{{
0
.
1
,
0
.
2
,
0
.
0
,
0
.
0
,
0
.
3
,
0
.
4
}}
};
static
const
float
data
[]
=
{
0
.
1
f
,
0
.
2
f
,
0
.
3
f
,
0
.
4
f
,
0
.
5
f
,
0
.
6
f
,
0
.
7
f
,
0
.
8
f
};
struct
test_context
test_context
;
ID3DXConstantTable
*
constants
;
ID3D10Blob
*
ps_code
=
NULL
;
IDirect3DDevice9
*
device
;
struct
vec4
v
;
HRESULT
hr
;
...
...
@@ -838,71 +837,132 @@ static void test_majority(void)
"typedef float2x2 matrix_t;
\n
"
"typedef row_major matrix_t row_matrix_t;
\n
"
"typedef column_major matrix_t col_matrix_t;
\n
"
"uniform row_matrix_t
r
;
\n
"
"uniform col_matrix_t
c
;
\n
"
"uniform row_matrix_t
m1
;
\n
"
"uniform col_matrix_t
m2
;
\n
"
"float4 main() : COLOR
\n
"
"{
\n
"
" float4 ret;
\n
"
" ret.xy = m
ul(r, float2(0.5, 0.6))
;
\n
"
" ret.zw = m
ul(c, float2(0.5, 0.6))
;
\n
"
" ret.xy = m
1[0]
;
\n
"
" ret.zw = m
2[0]
;
\n
"
" return ret;
\n
"
"}"
;
static
const
char
ps_
default
_source
[]
=
static
const
char
ps_
pragmas
_source
[]
=
"#pragma pack_matrix(row_major)
\n
"
"uniform float2x2
r
;
\n
"
"uniform float2x2
m1
;
\n
"
"#pragma pack_matrix(column_major)
\n
"
"uniform float2x2 c;
\n
"
"uniform float2x2 m2;
\n
"
"float4 main() : COLOR
\n
"
"{
\n
"
" float4 ret;
\n
"
" ret.xy = m1[0];
\n
"
" ret.zw = m2[0];
\n
"
" return ret;
\n
"
"}"
;
static
const
char
ps_row_source
[]
=
"uniform row_major float2x2 m1;
\n
"
"uniform row_major float2x2 m2;
\n
"
"float4 main() : COLOR
\n
"
"{
\n
"
" float4 ret;
\n
"
" ret.xy = m1[0];
\n
"
" ret.zw = m2[0];
\n
"
" return ret;
\n
"
"}"
;
static
const
char
ps_column_source
[]
=
"uniform column_major float2x2 m1;
\n
"
"uniform column_major float2x2 m2;
\n
"
"float4 main() : COLOR
\n
"
"{
\n
"
" float4 ret;
\n
"
" ret.xy = m1[0];
\n
"
" ret.zw = m2[0];
\n
"
" return ret;
\n
"
"}"
;
static
const
char
ps_no_modifiers_source
[]
=
"uniform float2x2 m1;
\n
"
"uniform float2x2 m2;
\n
"
"float4 main() : COLOR
\n
"
"{
\n
"
" float4 ret;
\n
"
" ret.xy = m
ul(r, float2(0.5, 0.6))
;
\n
"
" ret.zw = m
ul(c, float2(0.5, 0.6))
;
\n
"
" ret.xy = m
1[0]
;
\n
"
" ret.zw = m
2[0]
;
\n
"
" return ret;
\n
"
"}"
;
static
const
struct
test
{
const
char
*
code
;
struct
vec4
color
;
unsigned
int
flags
;
}
tests
[]
=
{
{
ps_typedef_source
,
{
0
.
1
f
,
0
.
2
f
,
0
.
1
f
,
0
.
5
f
}
},
{
ps_pragmas_source
,
{
0
.
1
f
,
0
.
2
f
,
0
.
1
f
,
0
.
5
f
}
},
{
ps_row_source
,
{
0
.
1
f
,
0
.
2
f
,
0
.
1
f
,
0
.
2
f
}
},
{
ps_column_source
,
{
0
.
1
f
,
0
.
5
f
,
0
.
1
f
,
0
.
5
f
}
},
{
ps_no_modifiers_source
,
{
0
.
1
f
,
0
.
2
f
,
0
.
1
f
,
0
.
2
f
},
D3DCOMPILE_PACK_MATRIX_ROW_MAJOR
},
{
ps_no_modifiers_source
,
{
0
.
1
f
,
0
.
5
f
,
0
.
1
f
,
0
.
5
f
},
D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR
},
{
ps_pragmas_source
,
{
0
.
1
f
,
0
.
2
f
,
0
.
1
f
,
0
.
5
f
},
D3DCOMPILE_PACK_MATRIX_ROW_MAJOR
},
{
ps_pragmas_source
,
{
0
.
1
f
,
0
.
2
f
,
0
.
1
f
,
0
.
5
f
},
D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR
},
};
unsigned
int
i
;
if
(
!
init_test_context
(
&
test_context
))
return
;
device
=
test_context
.
device
;
ps_code
=
compile_shader
(
ps_typedef_source
,
"ps_2_0"
);
if
(
ps_code
)
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
tests
);
++
i
)
{
hr
=
pD3DXGetShaderConstantTable
(
ID3D10Blob_GetBufferPointer
(
ps_code
),
&
constants
);
ok
(
hr
==
D3D_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID3DXConstantTable_SetMatrix
(
constants
,
device
,
"r"
,
&
matrix
);
ok
(
hr
==
D3D_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID3DXConstantTable_SetMatrix
(
constants
,
device
,
"c"
,
&
matrix
);
ok
(
hr
==
D3D_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
ID3DXConstantTable_Release
(
constants
);
const
struct
vec4
*
c
=
&
tests
[
i
].
color
;
draw_quad
(
test_context
.
device
,
ps_code
);
winetest_push_context
(
"Test %u"
,
i
);
v
=
get_color_vec4
(
test_context
.
device
,
0
,
0
);
ok
(
compare_vec4
(
&
v
,
0
.
17
f
,
0
.
39
f
,
0
.
17
f
,
0
.
39
f
,
1
),
"Got unexpected value {%.8e, %.8e, %.8e, %.8e}.
\n
"
,
v
.
x
,
v
.
y
,
v
.
z
,
v
.
w
);
ps_code
=
compile_shader
(
tests
[
i
].
code
,
"ps_2_0"
,
tests
[
i
].
flags
);
if
(
ps_code
)
{
ID3DXConstantTable
*
constants
;
D3DXCONSTANT_DESC
desc
;
D3DXHANDLE
h
;
UINT
count
;
ID3D10Blob_Release
(
ps_code
);
}
hr
=
pD3DXGetShaderConstantTable
(
ID3D10Blob_GetBufferPointer
(
ps_code
),
&
constants
);
ok
(
hr
==
D3D_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
ps_code
=
compile_shader
(
ps_default_source
,
"ps_2_0"
);
if
(
ps_code
)
{
hr
=
pD3DXGetShaderConstantTable
(
ID3D10Blob_GetBufferPointer
(
ps_code
),
&
constants
);
ok
(
hr
==
D3D_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID3DXConstantTable_SetMatrix
(
constants
,
device
,
"r"
,
&
matrix
);
ok
(
hr
==
D3D_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID3DXConstantTable_SetMatrix
(
constants
,
device
,
"c"
,
&
matrix
);
ok
(
hr
==
D3D_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
ID3DXConstantTable_Release
(
constants
);
h
=
ID3DXConstantTable_GetConstantByName
(
constants
,
NULL
,
"m1"
);
ok
(
!!
h
,
"Failed to find a constant.
\n
"
);
count
=
1
;
hr
=
ID3DXConstantTable_GetConstantDesc
(
constants
,
h
,
&
desc
,
&
count
);
ok
(
hr
==
D3D_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IDirect3DDevice9_SetPixelShaderConstantF
(
test_context
.
device
,
desc
.
RegisterIndex
,
data
,
desc
.
RegisterCount
);
ok
(
hr
==
D3D_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
draw_quad
(
test_context
.
device
,
ps_code
);
h
=
ID3DXConstantTable_GetConstantByName
(
constants
,
NULL
,
"m2"
);
ok
(
!!
h
,
"Failed to find a constant.
\n
"
);
count
=
1
;
hr
=
ID3DXConstantTable_GetConstantDesc
(
constants
,
h
,
&
desc
,
&
count
);
ok
(
hr
==
D3D_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IDirect3DDevice9_SetPixelShaderConstantF
(
test_context
.
device
,
desc
.
RegisterIndex
,
data
,
desc
.
RegisterCount
);
ok
(
hr
==
D3D_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
v
=
get_color_vec4
(
test_context
.
device
,
0
,
0
);
ok
(
compare_vec4
(
&
v
,
0
.
17
f
,
0
.
39
f
,
0
.
17
f
,
0
.
39
f
,
1
),
ID3DXConstantTable_Release
(
constants
);
draw_quad
(
test_context
.
device
,
ps_code
);
v
=
get_color_vec4
(
test_context
.
device
,
0
,
0
);
todo_wine_if
(
i
==
4
)
ok
(
compare_vec4
(
&
v
,
c
->
x
,
c
->
y
,
c
->
z
,
c
->
w
,
1
),
"Got unexpected value {%.8e, %.8e, %.8e, %.8e}.
\n
"
,
v
.
x
,
v
.
y
,
v
.
z
,
v
.
w
);
ID3D10Blob_Release
(
ps_code
);
ID3D10Blob_Release
(
ps_code
);
}
winetest_pop_context
();
}
release_test_context
(
&
test_context
);
...
...
@@ -935,7 +995,7 @@ static void test_struct_assignment(void)
if
(
!
init_test_context
(
&
test_context
))
return
;
ps_code
=
compile_shader
(
ps_source
,
"ps_2_0"
);
ps_code
=
compile_shader
(
ps_source
,
"ps_2_0"
,
0
);
draw_quad
(
test_context
.
device
,
ps_code
);
v
=
get_color_vec4
(
test_context
.
device
,
0
,
0
);
...
...
@@ -977,7 +1037,7 @@ static void test_struct_semantics(void)
if
(
!
init_test_context
(
&
test_context
))
return
;
ps_code
=
compile_shader
(
ps_source
,
"ps_2_0"
);
ps_code
=
compile_shader
(
ps_source
,
"ps_2_0"
,
0
);
draw_quad
(
test_context
.
device
,
ps_code
);
v
=
get_color_vec4
(
test_context
.
device
,
64
,
48
);
...
...
@@ -1016,7 +1076,7 @@ static void test_global_initializer(void)
if
(
!
init_test_context
(
&
test_context
))
return
;
todo_wine
ps_code
=
compile_shader
(
ps_source
,
"ps_2_0"
);
todo_wine
ps_code
=
compile_shader
(
ps_source
,
"ps_2_0"
,
0
);
if
(
ps_code
)
{
hr
=
pD3DXGetShaderConstantTable
(
ID3D10Blob_GetBufferPointer
(
ps_code
),
&
constants
);
...
...
@@ -1103,7 +1163,7 @@ static void test_samplers(void)
{
hr
=
IDirect3DDevice9_Clear
(
test_context
.
device
,
0
,
NULL
,
D3DCLEAR_TARGET
,
D3DCOLOR_XRGB
(
255
,
0
,
0
),
1
.
0
f
,
0
);
ok
(
hr
==
D3D_OK
,
"Test %u: Got unexpected hr %#lx.
\n
"
,
i
,
hr
);
ps_code
=
compile_shader
(
tests
[
i
],
"ps_2_0"
);
ps_code
=
compile_shader
(
tests
[
i
],
"ps_2_0"
,
0
);
if
(
ps_code
)
{
draw_quad
(
test_context
.
device
,
ps_code
);
...
...
@@ -1229,7 +1289,7 @@ static void test_constant_table(void)
static
const
D3DXCONSTANT_DESC
expect_fields_j
=
{
"a"
,
D3DXRS_FLOAT4
,
0
,
3
,
D3DXPC_MATRIX_COLUMNS
,
D3DXPT_FLOAT
,
3
,
3
,
1
,
0
,
36
};
todo_wine
ps_code
=
compile_shader
(
source
,
"ps_2_0"
);
todo_wine
ps_code
=
compile_shader
(
source
,
"ps_2_0"
,
0
);
if
(
!
ps_code
)
return
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment