26#define D3DXERR_INVALIDDATA 0x88760b59
101#define compile_shader(a, b, c) compile_shader_(__LINE__, a, b, c)
108 hr =
D3DCompile(
source,
strlen(
source),
NULL,
NULL,
NULL,
"main",
target,
flags, 0, &
blob, &errors);
113 trace_(__FILE__,
line)(
"%s\n", (
char *)ID3D10Blob_GetBufferPointer(errors));
114 ID3D10Blob_Release(errors);
126 .BackBufferWidth = 640,
127 .BackBufferHeight = 480,
139 skip(
"Failed to create a D3D object.\n");
148 skip(
"Failed to create a 3D device, hr %#lx.\n",
hr);
156 skip(
"No shader model 2 support.\n");
164 skip(
"Failed to create an A32B32G32R32F surface, hr %#lx.\n",
hr);
182#define init_test_context(a) init_test_context_(__LINE__, a)
190 ok(!!
context->window,
"Failed to create a window.\n");
201#define release_test_context(context) release_test_context_(__LINE__, context)
205 ok_(__FILE__,
line)(!
ref,
"Device has %lu references left.\n",
ref);
209#define draw_quad(device, ps_code) draw_quad_(__LINE__, device, ps_code)
212 IDirect3DVertexDeclaration9 *vertex_declaration;
213 IDirect3DVertexShader9 *
vs;
214 IDirect3DPixelShader9 *ps;
227 struct vec2 position;
232 {{-1.0f, -1.0f}, {0.0f, 1.0f}},
233 {{-1.0f, 1.0f}, {0.0f, 0.0f}},
234 {{ 1.0f, -1.0f}, {1.0f, 1.0f}},
235 {{ 1.0f, 1.0f}, {1.0f, 0.0f}},
238 static const char vs_source[] =
239 "float4 main(float4 pos : POSITION, inout float2 texcoord : TEXCOORD0) : POSITION\n"
245 ok_(__FILE__,
line)(
hr ==
D3D_OK,
"Failed to create vertex declaration, hr %#lx.\n",
hr);
248 ok_(__FILE__,
line)(
hr ==
D3D_OK,
"Failed to set vertex declaration, hr %#lx.\n",
hr);
253 ok_(__FILE__,
line)(
hr ==
D3D_OK,
"Failed to create vertex shader, hr %#lx.\n",
hr);
256 ok_(__FILE__,
line)(
hr ==
D3D_OK,
"Failed to set vertex shader, hr %#lx.\n",
hr);
259 ok_(__FILE__,
line)(
hr ==
D3D_OK,
"Failed to create pixel shader, hr %#lx.\n",
hr);
276 ID3D10Blob_Release(vs_code);
334 unsigned int diff =
x >
y ?
x -
y :
y -
x;
336 return diff <= max_diff;
379 "uniform float4 color;\n"
380 "float4 main() : COLOR\n"
382 " float4 ret = color;\n"
383 " ret.gb = ret.ra;\n"
384 " ret.ra = float2(0.0101, 0.0404);\n"
387 {0.0101f, 0.0303f, 0.0202f, 0.0404f}
390 "float4 main() : COLOR\n"
392 " float4 ret = float4(0.1, 0.2, 0.3, 0.4);\n"
393 " ret.wyz.yx = float2(0.5, 0.6).yx;\n"
396 {0.1f, 0.6f, 0.3f, 0.5f}
399 "float4 main() : COLOR\n"
402 " ret.zwyx = float4(0.1, 0.2, 0.3, 0.4);\n"
405 {0.4f, 0.3f, 0.1f, 0.2f}
408 "float4 main() : COLOR\n"
412 " ret.xzy.yz.y.x = 0.2;\n"
413 " ret.yzwx.yzwx.wz.y = 0.3;\n"
414 " ret.zxy.xyz.zxy.xy.y = 0.4;\n"
417 {0.3f, 0.2f, 0.4f, 0.1f}
420 "float4 main() : COLOR\n"
423 " ret.yxz.yx = float2(0.1, 0.2);\n"
425 " ret.wzyx.zyx.yx.x = 0.4;\n"
428 {0.1f, 0.2f, 0.4f, 0.3f}
431 "float4 main() : COLOR\n"
433 " float4 ret = float4(0.1, 0.2, 0.3, 0.4).ywxz.zyyz;\n"
436 {0.1f, 0.4f, 0.4f, 0.1f}
439 "float4 main() : COLOR\n"
441 " float4 ret = float4(0.1, 0.2, 0.3, 0.4);\n"
446 {0.3f, 0.1f, 0.4f, 0.2f}
449 "float4 main() : COLOR\n"
452 " ret.xyzw.xyzw = float4(0.1, 0.2, 0.3, 0.4);\n"
455 {0.1f, 0.2f, 0.3f, 0.4f}
468 hr = pD3DXGetShaderConstantTable(ID3D10Blob_GetBufferPointer(ps_code), &
constants);
478 "Test %u: Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n",
i,
v.x,
v.y,
v.z,
v.w);
480 ID3D10Blob_Release(ps_code);
495 static const char ps_source[] =
496 "float4 main(uniform float u, uniform float v, uniform float w, uniform float x,\n"
497 " uniform float y, uniform float z): COLOR\n"
499 " return float4(x * y - z / w + --u / -v,\n"
500 " z * x / y + w / -v,\n"
510 hr = pD3DXGetShaderConstantTable(ID3D10Blob_GetBufferPointer(ps_code), &
constants);
530 "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n",
v.x,
v.y,
v.z,
v.w);
532 ID3D10Blob_Release(ps_code);
541 const struct vec4 *
v;
545 static const char ps_if_source[] =
546 "float4 main(float2 pos : TEXCOORD0) : COLOR\n"
548 " if((pos.x * 640.0) > 200.0)\n"
549 " return float4(0.1, 0.2, 0.3, 0.4);\n"
551 " return float4(0.9, 0.8, 0.7, 0.6);\n"
554 static const char ps_ternary_source[] =
555 "float4 main(float2 pos : TEXCOORD0) : COLOR\n"
557 " return (pos.x < 0.5 ? float4(0.5, 0.25, 0.5, 0.75) : float4(0.6, 0.8, 0.1, 0.2));\n"
571 for (
i = 0;
i < 200;
i += 40)
575 "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n",
v->x,
v->y,
v->z,
v->w);
578 for (
i = 240;
i < 640;
i += 40)
582 "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n",
v->x,
v->y,
v->z,
v->w);
586 ID3D10Blob_Release(ps_code);
595 for (
i = 0;
i < 320;
i += 40)
599 "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n",
v->x,
v->y,
v->z,
v->w);
602 for (
i = 360;
i < 640;
i += 40)
606 "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n",
v->x,
v->y,
v->z,
v->w);
610 ID3D10Blob_Release(ps_code);
625 static const char ps_indexing_source[] =
626 "float4 main() : COLOR\n"
629 " color[0] = 0.020;\n"
630 " color[1] = 0.245;\n"
631 " color[2] = 0.351;\n"
637 static const char ps_uniform_indexing_source[] =
639 "float4 main() : COLOR\n"
641 " float4 color = float4(0.5, 0.4, 0.3, 0.2);\n"
642 " color.g = color[i];\n"
658 "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n",
v.x,
v.y,
v.z,
v.w);
660 ID3D10Blob_Release(ps_code);
663 ps_code =
compile_shader(ps_uniform_indexing_source,
"ps_2_0", 0);
666 hr = pD3DXGetShaderConstantTable(ID3D10Blob_GetBufferPointer(ps_code), &
constants);
675 "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n",
v.x,
v.y,
v.z,
v.w);
677 ID3D10Blob_Release(ps_code);
688 const struct vec4 *
v;
692 static const char ps_source[] =
693 "float4 main(float x : TEXCOORD0) : COLOR\n"
695 " const float pi2 = 6.2831853;\n"
696 " float calcd_sin = (sin(x * pi2) + 1)/2;\n"
697 " float calcd_cos = (cos(x * pi2) + 1)/2;\n"
698 " return float4(calcd_sin, calcd_cos, 0, 0);\n"
708 for (
i = 0;
i < 32; ++
i)
710 float expect_x = (
sinf(
i * 2 *
M_PI / 32) + 1.0f) / 2.0f;
711 float expect_y = (
cosf(
i * 2 *
M_PI / 32) + 1.0f) / 2.0f;
714 "Test %u: Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
715 i,
v->x,
v->y,
v->z,
v->w, expect_x, expect_y, 0.0f, 0.0f);
718 ID3D10Blob_Release(ps_code);
728 static const char ps_source[] =
729 "float4 main(float x: TEXCOORD0): COLOR\n"
732 " return (ret = float4(0.1, 0.2, 0.3, 0.4)), ret + 0.5;\n"
743 "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n",
v.x,
v.y,
v.z,
v.w);
745 ID3D10Blob_Release(ps_code);
755 static const char *void_source =
756 "void main(float x : TEXCOORD0, out float4 ret : COLOR)\n"
758 " ret = float4(0.1, 0.2, 0.3, 0.4);\n"
760 " ret = float4(0.5, 0.6, 0.7, 0.8);\n"
763 static const char *implicit_conversion_source =
764 "float4 main(float x : TEXCOORD0) : COLOR\n"
766 " return float2x2(0.4, 0.3, 0.2, 0.1);\n"
777 "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n",
v.x,
v.y,
v.z,
v.w);
779 ID3D10Blob_Release(ps_code);
781 ps_code =
compile_shader(implicit_conversion_source,
"ps_2_0", 0);
788 "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n",
v.x,
v.y,
v.z,
v.w);
790 ID3D10Blob_Release(ps_code);
802 static const char shader[] =
803 "float4 main(float x : TEXCOORD0) : COLOR\n"
805 " const int dim = 4;\n"
806 " float a[2 * 2] = {0.1, 0.2, 0.3, 0.4};\n"
807 " float b[4.1] = a;\n"
808 " float c[dim] = b;\n"
809 " float d[true] = {c[0]};\n"
811 " return float4(d[0], c[0], c[1], c[3]);\n"
824 "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n",
v.x,
v.y,
v.z,
v.w);
826 ID3D10Blob_Release(ps_code);
834 static const float data[] = { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f };
840 static const char ps_typedef_source[] =
841 "typedef float2x2 matrix_t;\n"
842 "typedef row_major matrix_t row_matrix_t;\n"
843 "typedef column_major matrix_t col_matrix_t;\n"
844 "uniform row_matrix_t m1;\n"
845 "uniform col_matrix_t m2;\n"
846 "float4 main() : COLOR\n"
854 static const char ps_pragmas_source[] =
855 "#pragma pack_matrix(row_major)\n"
856 "uniform float2x2 m1;\n"
857 "#pragma pack_matrix(column_major)\n"
858 "uniform float2x2 m2;\n"
859 "float4 main() : COLOR\n"
867 static const char ps_row_source[] =
868 "uniform row_major float2x2 m1;\n"
869 "uniform row_major float2x2 m2;\n"
870 "float4 main() : COLOR\n"
878 static const char ps_column_source[] =
879 "uniform column_major float2x2 m1;\n"
880 "uniform column_major float2x2 m2;\n"
881 "float4 main() : COLOR\n"
889 static const char ps_no_modifiers_source[] =
890 "uniform float2x2 m1;\n"
891 "uniform float2x2 m2;\n"
892 "float4 main() : COLOR\n"
900 static const struct test
908 { ps_typedef_source, { 0.1f, 0.2f, 0.1f, 0.5f } },
909 { ps_pragmas_source, { 0.1f, 0.2f, 0.1f, 0.5f } },
910 { ps_row_source, { 0.1f, 0.2f, 0.1f, 0.2f } },
911 { ps_column_source, { 0.1f, 0.5f, 0.1f, 0.5f } },
937 hr = pD3DXGetShaderConstantTable(ID3D10Blob_GetBufferPointer(ps_code), &
constants);
941 ok(!!
h,
"Failed to find a constant.\n");
950 ok(!!
h,
"Failed to find a constant.\n");
964 "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n",
v.x,
v.y,
v.z,
v.w);
966 ID3D10Blob_Release(ps_code);
981 static const char ps_source[] =
990 "float4 main() : COLOR\n"
992 " struct apple q, r, s;\n"
993 " q.m.a = float4(0.1, 0.2, 0.3, 0.4);\n"
994 " q.b = float4(0.5, 0.1, 0.4, 0.5);\n"
996 " return s.m.a + s.b;\n"
1007 "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n",
v.x,
v.y,
v.z,
v.w);
1009 ID3D10Blob_Release(ps_code);
1019 static const char ps_source[] =
1024 " float4 texcoord : TEXCOORD0;\n"
1031 " float4 color : COLOR;\n"
1034 "struct output main(struct input i)\n"
1036 " struct output o;\n"
1037 " o.m.color = i.m.texcoord;\n"
1050 "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n",
v.x,
v.y,
v.z,
v.w);
1054 "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n",
v.x,
v.y,
v.z,
v.w);
1056 ID3D10Blob_Release(ps_code);
1068 static const char ps_source[] =
1073 "static float sf = myfunc() + 0.2;\n"
1074 "uniform float uf = 0.2;\n"
1075 "float4 main() : COLOR\n"
1077 " return float4(sf, uf, 0, 0);\n"
1084 hr = pD3DXGetShaderConstantTable(ID3D10Blob_GetBufferPointer(ps_code), &
constants);
1093 "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n",
v.x,
v.y,
v.z,
v.w);
1095 ID3D10Blob_Release(ps_code);
1109 static const char *
tests[] =
1112 "float4 main() : COLOR\n"
1114 " return tex2D(s, float2(0.75, 0.25));\n"
1118 "float4 main() : COLOR\n"
1120 " return tex2D(s, float2(0.75, 0.25));\n"
1124 "float4 main() : COLOR\n"
1126 " return tex2D(s, float2(0.75, 0.25));\n"
1131 "float4 main() : COLOR\n"
1133 " return t.Sample(s, float2(0.75, 0.25));\n"
1138 "float4 main() : COLOR\n"
1140 " return t.Sample(s, float2(0.75, 0.25));\n"
1166 ok(
hr ==
D3D_OK,
"Test %u: Got unexpected hr %#lx.\n",
i,
hr);
1175 "Test %u: Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n",
i,
v.x,
v.y,
v.z,
v.w);
1177 ID3D10Blob_Release(ps_code);
1191 ok(
desc->RegisterIndex ==
expect->RegisterIndex,
"%s: got RegisterIndex %u.\n",
prefix,
desc->RegisterIndex);
1192 ok(
desc->RegisterCount ==
expect->RegisterCount,
"%s: got RegisterCount %u.\n",
prefix,
desc->RegisterCount);
1198 ok(
desc->StructMembers ==
expect->StructMembers,
"%s: got StructMembers %u.\n",
prefix,
desc->StructMembers);
1205 static const char *
source =
1206 "typedef float3x3 matrix_t;\n"
1207 "struct matrix_record { float3x3 a; } dummy;\n"
1208 "uniform float4 a;\n"
1209 "uniform float b;\n"
1210 "uniform float unused;\n"
1211 "uniform float3x1 c;\n"
1212 "uniform row_major float3x1 d;\n"
1219 "#pragma pack_matrix(row_major)\n"
1222 "uniform bool2 g[5];\n"
1223 "uniform matrix_t i;\n"
1224 "uniform struct matrix_record j;\n"
1225 "uniform matrix<float,3,1> k;\n"
1226 "sampler l : register(s5);\n"
1228 "texture dummy_texture;\n"
1231 " Texture = dummy_texture;\n"
1236 " Texture = dummy_texture;\n"
1240 "sampler q : register(s7);\n"
1241 "SamplerState r : register(s8);\n"
1243 "float4 main(uniform float4 h, sampler t, uniform sampler u) : COLOR\n"
1245 " return b + c._31 + d._31 + f.d._22 + tex2D(l, g[e]) + tex3D(m, h.xyz) + i._33 + j.a._33 + k._31\n"
1246 " + tex2D(n, a.xy) + tex2D(o, a.xy) + p.Sample(r, a.xy) + p.Sample(q, a.xy) + tex2D(s, a.xy)\n"
1247 " + tex2D(t, a.xy) + tex2D(u, a.xy);\n"
1261 {
"$h",
D3DXRS_FLOAT4, 0, 1,
D3DXPC_VECTOR,
D3DXPT_FLOAT, 1, 4, 1, 0, 16},
1262 {
"$u",
D3DXRS_SAMPLER, 10, 1,
D3DXPC_OBJECT,
D3DXPT_SAMPLER2D, 1, 1, 1, 0, 4},
1263 {
"a",
D3DXRS_FLOAT4, 0, 1,
D3DXPC_VECTOR,
D3DXPT_FLOAT, 1, 4, 1, 0, 16},
1264 {
"b",
D3DXRS_FLOAT4, 0, 1,
D3DXPC_SCALAR,
D3DXPT_FLOAT, 1, 1, 1, 0, 4},
1265 {
"c",
D3DXRS_FLOAT4, 0, 1,
D3DXPC_MATRIX_COLUMNS,
D3DXPT_FLOAT, 3, 1, 1, 0, 12},
1266 {
"d",
D3DXRS_FLOAT4, 0, 3,
D3DXPC_MATRIX_ROWS,
D3DXPT_FLOAT, 3, 1, 1, 0, 12},
1267 {
"e",
D3DXRS_FLOAT4, 0, 1,
D3DXPC_SCALAR,
D3DXPT_INT, 1, 1, 1, 0, 4},
1268 {
"f",
D3DXRS_FLOAT4, 0, 7,
D3DXPC_STRUCT,
D3DXPT_VOID, 1, 11, 1, 4, 44},
1269 {
"g",
D3DXRS_FLOAT4, 0, 5,
D3DXPC_VECTOR,
D3DXPT_BOOL, 1, 2, 5, 0, 40},
1270 {
"i",
D3DXRS_FLOAT4, 0, 3,
D3DXPC_MATRIX_ROWS,
D3DXPT_FLOAT, 3, 3, 1, 0, 36},
1271 {
"j",
D3DXRS_FLOAT4, 0, 3,
D3DXPC_STRUCT,
D3DXPT_VOID, 1, 9, 1, 1, 36},
1272 {
"k",
D3DXRS_FLOAT4, 0, 3,
D3DXPC_MATRIX_ROWS,
D3DXPT_FLOAT, 3, 1, 1, 0, 12},
1273 {
"l",
D3DXRS_SAMPLER, 5, 1,
D3DXPC_OBJECT,
D3DXPT_SAMPLER2D, 1, 1, 1, 0, 4},
1274 {
"m",
D3DXRS_SAMPLER, 2, 1,
D3DXPC_OBJECT,
D3DXPT_SAMPLER3D, 1, 1, 1, 0, 4},
1275 {
"n",
D3DXRS_SAMPLER, 3, 1,
D3DXPC_OBJECT,
D3DXPT_SAMPLER2D, 1, 1, 1, 0, 4},
1276 {
"o",
D3DXRS_SAMPLER, 4, 1,
D3DXPC_OBJECT,
D3DXPT_SAMPLER2D, 1, 1, 1, 0, 4},
1277 {
"q+p",
D3DXRS_SAMPLER, 0, 1,
D3DXPC_OBJECT,
D3DXPT_TEXTURE2D, 1, 4, 1, 0, 16},
1278 {
"r+p",
D3DXRS_SAMPLER, 1, 1,
D3DXPC_OBJECT,
D3DXPT_TEXTURE2D, 1, 4, 1, 0, 16},
1279 {
"s",
D3DXRS_SAMPLER, 6, 1,
D3DXPC_OBJECT,
D3DXPT_SAMPLER2D, 1, 1, 1, 0, 4},
1280 {
"t",
D3DXRS_SAMPLER, 9, 1,
D3DXPC_OBJECT,
D3DXPT_SAMPLER2D, 1, 1, 1, 0, 4},
1285 {
"a",
D3DXRS_FLOAT4, 0, 2,
D3DXPC_MATRIX_COLUMNS,
D3DXPT_FLOAT, 2, 2, 1, 0, 16},
1286 {
"b",
D3DXRS_FLOAT4, 0, 2,
D3DXPC_SCALAR,
D3DXPT_FLOAT, 1, 1, 2, 0, 8},
1287 {
"c",
D3DXRS_FLOAT4, 0, 1,
D3DXPC_SCALAR,
D3DXPT_FLOAT, 1, 1, 1, 0, 4},
1288 {
"d",
D3DXRS_FLOAT4, 0, 2,
D3DXPC_MATRIX_ROWS,
D3DXPT_FLOAT, 2, 2, 1, 0, 16},
1292 {
"a",
D3DXRS_FLOAT4, 0, 3,
D3DXPC_MATRIX_COLUMNS,
D3DXPT_FLOAT, 3, 3, 1, 0, 36};
1298 hr = pD3DXGetShaderConstantTable(ID3D10Blob_GetBufferPointer(ps_code), &
constants);
1311 ok(!!
handle,
"Failed to get constant.\n");
1325 ok(!!
field,
"Failed to get constant.\n");
1338 ok(!!
field,
"Failed to get constant.\n");
1350 ID3D10Blob_Release(ps_code);
1355 static const char *
tests[] =
1358 "float4 test() : SV_TARGET\n"
1363 "float4 test() : SV_TARGET\n"
1365 " float4 x = float4(0, 0, 0, 0);\n"
1366 " x.xzzx = float4(1, 2, 3, 4);\n"
1370 "float4 test(float2 pos: TEXCOORD0) : SV_TARGET\n"
1372 " float4 x = pos;\n"
1376 "float4 test(float2 pos, TEXCOORD0) ; SV_TARGET\n"
1378 " pos = float4 x;\n"
1379 " mul(float4(5, 4, 3, 2), mvp) = x;\n"
1383 "float4 563r(float2 45s: TEXCOORD0) : SV_TARGET\n"
1385 " float2 x = 45s;\n"
1386 " return float4(x.x, x.y, 0, 0);\n"
1390 "float4 test() : SV_TARGET\n"
1392 " struct { int b,c; } x = {0};\n"
1396 "float4 test() : SV_TARGET\n"
1398 " struct {} x = {};\n"
1402 "float4 test(float2 pos : TEXCOORD0) : SV_TARGET\n"
1407 "void test(float2 pos : TEXCOORD0)\n"
1412 "float4 test(float2 pos : TEXCOORD0) : SV_TARGET\n"
1418 "float4 test(float2 pos: TEXCOORD0) : SV_TARGET\n"
1421 " return float4(0, 0, 0, 0);\n"
1424 "float4 test(float2 pos: TEXCOORD0) : SV_TARGET\n"
1426 " float a[65537];\n"
1427 " return float4(0, 0, 0, 0);\n"
1430 "float4 test(float2 pos: TEXCOORD0) : SV_TARGET\n"
1433 " float a[(x = 2)];\n"
1434 " return float4(0, 0, 0, 0);\n"
1437 "uniform float4 test() : SV_TARGET\n"
1439 " return float4(0, 0, 0, 0);\n"
1442 "typedef row_major float4x4 matrix_t;\n"
1443 "typedef column_major matrix_t matrix2_t;\n"
1444 "float4 test() : SV_TARGET\n"
1446 " return float4(0, 0, 0, 0);\n"
1452 " return float4(0, 0, 0, 0);\n"
1455 "float4 test(out float4 o : SV_TARGET)\n"
1457 " o = float4(1, 1, 1, 1);\n"
1458 " return float4(0, 0, 0, 0);\n"
1461 "struct {float4 a;};\n"
1462 "float4 test() : SV_TARGET\n"
1464 " return float4(0, 0, 0, 0);\n"
1468 static const char *targets[] = {
"ps_2_0",
"ps_3_0",
"ps_4_0"};
1479 compiled = (
void *)0xdeadbeef;
1480 hr =
D3DCompile(
tests[
i],
strlen(
tests[
i]),
NULL,
NULL,
NULL,
"test", targets[
j], 0, 0, &compiled, &errors);
1481 ok(
hr ==
E_FAIL,
"Test %u, target %s: Got unexpected hr %#lx.\n",
i, targets[
j],
hr);
1482 ok(!!errors,
"Test %u, target %s, expected non-NULL error blob.\n",
i, targets[
j]);
1483 ID3D10Blob_Release(errors);
1484 ok(!compiled,
"Test %u, target %s, expected no compiled shader blob.\n",
i, targets[
j]);
1492 static const char include1[] =
1493 "#define LIGHT 1\n";
1494 static const char include2[] =
1495 "#include \"include1.h\"\n"
1496 "float4 light_color = LIGHT;\n";
1497 static const char include3[] =
1498 "#include \"include1.h\"\n"
1499 "def c0, LIGHT, 0, 0, 0\n";
1503 trace(
"parent_data %p: %s.\n", parent_data, parent_data ? (
char *)parent_data :
"(null)");
1510 ok(include_type == D3D_INCLUDE_LOCAL,
"Unexpected include type %d.\n", include_type);
1512 "Unexpected parent_data value.\n");
1519 ok(!parent_data,
"Unexpected parent_data value.\n");
1520 ok(include_type == D3D_INCLUDE_LOCAL,
"Unexpected include type %d.\n", include_type);
1527 ok(!parent_data,
"Unexpected parent_data value.\n");
1528 ok(include_type == D3D_INCLUDE_LOCAL,
"Unexpected include type %d.\n", include_type);
1532 ok(0,
"Unexpected #include for file %s.\n",
filename);
1559 static const char ps_code[] =
1561 "#include \"include\\include3.h\"\n"
1564 return pD3DAssemble(ps_code,
sizeof(ps_code), source_name,
NULL,
include, 0,
blob, errors);
1569 static const char ps_code[] =
1570 "#include \"include\\include2.h\"\n"
1572 "float4 main() : COLOR\n"
1574 " return light_color;\n"
1577 return D3DCompile(ps_code,
sizeof(ps_code), source_name,
NULL,
include,
"main",
"ps_2_0", 0, 0,
blob, errors);
1580#if D3D_COMPILER_VERSION >= 46
1583 static const char ps_code[] =
1584 "#include \"include\\include2.h\"\n"
1586 "float4 main() : COLOR\n"
1588 " return light_color;\n"
1592 "main",
"ps_2_0", 0, 0, 0,
NULL, 0,
blob, errors);
1598 static const char ps_code[] =
1599 "#include \"include\\include2.h\"\n"
1618 static const char ps_code[] =
1619 "#include \"include\\include2.h\"\n"
1621 "float4 main() : COLOR\n"
1623 " return light_color;\n"
1625 static const char include1[] =
1626 "#define LIGHT 1\n";
1627 static const char include1_wrong[] =
1628 "#define LIGHT nope\n";
1629 static const char include2[] =
1630 "#include \"include1.h\"\n"
1631 "float4 light_color = LIGHT;\n";
1632 static const char include3[] =
1633 "#include \"include1.h\"\n"
1634 "def c0, LIGHT, 0, 0, 0\n";
1636#if D3D_COMPILER_VERSION >= 46
1638 static const char ps_absolute_template[] =
1639 "#include \"%ls\"\n"
1641 "float4 main() : COLOR\n"
1643 " return light_color;\n"
1645 char ps_absolute_buffer[
sizeof(ps_absolute_template) +
MAX_PATH];
1653#if D3D_COMPILER_VERSION >= 46
1675 ok(
hr ==
S_OK,
"Got unexpected hr %#lx.\n",
hr);
1676 ok(!!
blob,
"Got unexpected blob.\n");
1679 ok(!errors,
"Got unexpected errors.\n");
1682 ID3D10Blob_Release(
blob);
1686#if D3D_COMPILER_VERSION >= 46
1690 ok(!
blob,
"Got unexpected blob.\n");
1691 ok(!!errors,
"Got unexpected errors.\n");
1692 ID3D10Blob_Release(errors);
1701 ok(
hr ==
S_OK,
"Got unexpected hr %#lx.\n",
hr);
1702 ok(!!
blob,
"Got unexpected blob.\n");
1703 ok(!errors,
"Got unexpected errors.\n");
1707 ID3D10Blob_Release(
blob);
1715#if D3D_COMPILER_VERSION >= 46
1719 ok(!
blob,
"Got unexpected blob.\n");
1720 ok(!errors,
"Got unexpected errors.\n");
1724 ok(!
blob,
"Got unexpected blob.\n");
1725 ok(!!errors,
"Got unexpected errors.\n");
1726 trace(
"%s.\n", (
char *)ID3D10Blob_GetBufferPointer(errors));
1727 ID3D10Blob_Release(errors);
1731 ok(
hr ==
S_OK,
"Got unexpected hr %#lx.\n",
hr);
1732 ok(!!
blob,
"Got unexpected blob.\n");
1733 ok(!errors,
"Got unexpected errors.\n");
1734 ID3D10Blob_Release(
blob);
1741 ok(
hr ==
S_OK,
"Got unexpected hr %#lx.\n",
hr);
1742 ok(!!
blob,
"Got unexpected blob.\n");
1743 ok(!errors,
"Got unexpected errors.\n");
1744 ID3D10Blob_Release(
blob);
1747 sprintf(ps_absolute_buffer, ps_absolute_template, include_filename);
1748 hr =
D3DCompile(ps_absolute_buffer,
sizeof(ps_absolute_buffer), filename_a,
NULL,
1752 todo_wine ok(!errors,
"Got unexpected errors.\n");
1755 ID3D10Blob_Release(
blob);
1769 ok(
hr ==
S_OK,
"Got unexpected hr %#lx.\n",
hr);
1770 ok(!!
blob,
"Got unexpected blob.\n");
1771 ok(!errors,
"Got unexpected errors.\n");
1775 ID3D10Blob_Release(
blob);
1783 ok(
hr ==
S_OK,
"Got unexpected hr %#lx.\n",
hr);
1784 ok(!!
blob,
"Got unexpected blob.\n");
1785 ok(!errors,
"Got unexpected errors.\n");
1786 ID3D10Blob_Release(
blob);
1801 static const char vs_source[] =
1802 "float4 main(float4 pos : POSITION, inout float2 texcoord : TEXCOORD0) : POSITION\n"
1809 errors = (
void *)0xdeadbeef;
1810 hr =
D3DCompile(vs_source,
strlen(vs_source),
NULL,
NULL,
NULL,
"main",
"vs_2_0", 0, 0,
NULL, &errors);
1812 ok(!errors,
"Unexpected errors blob.\n");
1817 static const char ps_hlsl[] =
1818 "float func(float x){return 0.1;}\n"
1819 "float func(half x){return 0.2;}\n"
1820 "float func(double x){return 0.3;}\n"
1822 "float4 main(uniform double u) : COLOR\n"
1824 " return func(u);\n"
1834 hr =
D3DCompile(ps_hlsl,
sizeof(ps_hlsl),
NULL,
NULL,
NULL,
"main",
"ps_2_0", 0, 0, &ps_bytecode, &errors);
1835#if D3D_COMPILER_VERSION >= 46
1842 trace(
"%s\n", (
char *)ID3D10Blob_GetBufferPointer(errors));
1850 ok(
compare_vec4(&
color, 0.3, 0.3, 0.3, 0.3, 0),
"Unexpected color {%.8e, %.8e, %.8e, %.8e}.\n",
1862 win_skip(
"Failed to load d3dx9_36.dll.\n");
1865 pD3DXGetShaderConstantTable = (
void *)
GetProcAddress(
mod,
"D3DXGetShaderConstantTable");
std::map< E_MODULE, HMODULE > mod
static unsigned char bytes[4]
#define D3DERR_INVALIDCALL
#define D3D_COMPILER_VERSION
#define D3DPS_VERSION(major, minor)
#define D3DVS_VERSION(major, minor)
#define D3DCOLOR_XRGB(r, g, b)
IDirect3D9 *WINAPI Direct3DCreate9(UINT SDKVersion)
#define IDirect3DDevice9_EndScene(p)
#define IDirect3DDevice9_BeginScene(p)
#define IDirect3DDevice9_CreatePixelShader(p, a, b)
#define IDirect3DDevice9_CreateVertexDeclaration(p, a, b)
#define IDirect3DSurface9_LockRect(p, a, b, c)
#define IDirect3D9_CreateDevice(p, a, b, c, d, e, f)
#define IDirect3DTexture9_UnlockRect(p, a)
#define IDirect3DDevice9_DrawPrimitiveUP(p, a, b, c, d)
#define IDirect3DDevice9_CreateTexture(p, a, b, c, d, e, f, g, h)
#define IDirect3DDevice9_GetRenderTargetData(p, a, b)
#define IDirect3DDevice9_SetRenderTarget(p, a, b)
#define IDirect3DDevice9_SetPixelShader(p, a)
#define IDirect3DDevice9_GetDeviceCaps(p, a)
#define IDirect3DVertexDeclaration9_Release(p)
#define IDirect3DPixelShader9_Release(p)
#define IDirect3D9_Release(p)
#define IDirect3DVertexShader9_Release(p)
#define IDirect3DDevice9_SetPixelShaderConstantF(p, a, b, c)
#define IDirect3DDevice9_SetVertexShader(p, a)
#define IDirect3DSurface9_GetDesc(p, a)
#define IDirect3DDevice9_Release(p)
#define IDirect3DDevice9_Clear(p, a, b, c, d, e, f)
#define IDirect3DTexture9_LockRect(p, a, b, c, d)
#define IDirect3DSurface9_UnlockRect(p)
#define IDirect3DSurface9_Release(p)
#define IDirect3DDevice9_SetTexture(p, a, b)
#define IDirect3DTexture9_Release(p)
#define IDirect3DDevice9_SetVertexDeclaration(p, a)
#define IDirect3DDevice9_CreateRenderTarget(p, a, b, c, d, e, f, g, h)
#define IDirect3DDevice9_CreateVertexShader(p, a, b)
#define IDirect3DDevice9_CreateOffscreenPlainSurface(p, a, b, c, d, e, f)
#define IDirect3DDevice9_SetSamplerState(p, a, b, c)
#define IDirect3DDevice9_GetRenderTarget(p, a, b)
#define D3DCOMPILE_PACK_MATRIX_ROW_MAJOR
#define D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR
#define D3D_COMPILE_STANDARD_FILE_INCLUDE
HRESULT WINAPI D3DPreprocess(const void *data, SIZE_T size, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, ID3DBlob **shader, ID3DBlob **error_messages)
HRESULT WINAPI D3DCompile(const void *data, SIZE_T data_size, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint, const char *target, UINT sflags, UINT eflags, ID3DBlob **shader, ID3DBlob **error_messages)
HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filename, const D3D_SHADER_MACRO *macros, ID3DInclude *include, const char *entry_point, const char *profile, UINT flags, UINT effect_flags, UINT secondary_flags, const void *secondary_data, SIZE_T secondary_data_size, ID3DBlob **shader_blob, ID3DBlob **messages_blob)
HRESULT WINAPI D3DCompileFromFile(const WCHAR *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint, const char *target, UINT flags1, UINT flags2, ID3DBlob **code, ID3DBlob **errors)
#define GetCurrentDirectoryW(x, y)
#define GetProcAddress(x, y)
#define INVALID_HANDLE_VALUE
#define FILE_ATTRIBUTE_NORMAL
#define WideCharToMultiByte
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
BOOL WINAPI WriteFile(_In_ HANDLE hFile, _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, _In_ DWORD nNumberOfBytesToWrite, _Out_opt_ LPDWORD lpNumberOfBytesWritten, _Inout_opt_ LPOVERLAPPED lpOverlapped)
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
_ACRTIMP float __cdecl cosf(float)
_ACRTIMP float __cdecl sinf(float)
_ACRTIMP size_t __cdecl strlen(const char *)
_ACRTIMP int __cdecl strcmp(const char *, const char *)
_ACRTIMP int __cdecl strncmp(const char *, const char *, size_t)
static char * strdup(const char *buf)
#define ID3DXConstantTable_GetDesc(p, a)
#define ID3DXConstantTable_Release(p)
#define ID3DXConstantTable_GetConstantDesc(p, a, b, c)
#define ID3DXConstantTable_SetDefaults(p, a)
#define ID3DXConstantTable_SetVector(p, a, b, c)
#define ID3DXConstantTable_SetFloat(p, a, b, c)
#define ID3DXConstantTable_GetConstant(p, a, b)
#define ID3DXConstantTable_SetInt(p, a, b, c)
#define ID3DXConstantTable_GetConstantByName(p, a, b)
GLint GLint GLint GLint GLint x
GLuint GLuint GLsizei count
GLint GLint GLint GLint GLint GLint y
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLubyte GLubyte GLubyte GLubyte w
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
static ID3D11Device * create_device(void)
static WCHAR temp_dir[MAX_PATH]
static void release_test_context_(unsigned int line, struct test_context *context)
static void test_swizzle(void)
static void draw_quad_(unsigned int line, IDirect3DDevice9 *device, ID3D10Blob *ps_code)
#define release_test_context(context)
#define init_test_context(a)
static void test_majority(void)
static HRESULT call_D3DAssemble(const char *source_name, ID3DInclude *include, ID3D10Blob **blob, ID3D10Blob **errors)
static BOOL compare_vec4(const struct vec4 *vec, float x, float y, float z, float w, unsigned int ulps)
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
static void delete_directory(const WCHAR *dir)
static void test_fail(void)
static void test_constant_table(void)
static ID3D10Blob * compile_shader_(unsigned int line, const char *source, const char *target, unsigned int flags)
static void test_include(void)
static void test_trig(void)
static void init_readback(IDirect3DDevice9 *device, struct readback *rb)
HRESULT(* include_test_cb)(const char *source_name, ID3DInclude *include, ID3D10Blob **blob, ID3D10Blob **errors)
static void test_comma(void)
static BOOL compare_uint(unsigned int x, unsigned int y, unsigned int max_diff)
static void test_array_dimensions(void)
static void test_return(void)
static BOOL create_directory(const WCHAR *dir)
#define D3DXERR_INVALIDDATA
static const struct vec4 * get_readback_vec4(const struct readback *rb, unsigned int x, unsigned int y)
#define compile_shader(a, b, c)
static void test_global_initializer(void)
static HRESULT WINAPI test_d3dinclude_open(ID3DInclude *iface, D3D_INCLUDE_TYPE include_type, const char *filename, const void *parent_data, const void **data, UINT *bytes)
static ID3DXConstantTable ** constant_table
static void test_math(void)
static HRESULT call_D3DPreprocess(const char *source_name, ID3DInclude *include, ID3D10Blob **blob, ID3D10Blob **errors)
static const struct ID3DIncludeVtbl test_d3dinclude_vtbl
static HRESULT WINAPI test_d3dinclude_close(ID3DInclude *iface, const void *data)
static struct vec4 get_color_vec4(IDirect3DDevice9 *device, unsigned int x, unsigned int y)
static void test_struct_semantics(void)
static void test_struct_assignment(void)
static void check_constant_desc(const char *prefix, const D3DXCONSTANT_DESC *desc, const D3DXCONSTANT_DESC *expect, BOOL nonzero_defaultvalue)
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ID3DBlob ** error_messages
static void test_conditionals(void)
static void test_samplers(void)
static void test_hlsl_double(void)
static void test_no_output_blob(void)
static HRESULT call_D3DCompile(const char *source_name, ID3DInclude *include, ID3D10Blob **blob, ID3D10Blob **errors)
static void test_float_vectors(void)
static void release_readback(struct readback *rb)
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT flags
#define draw_quad(device, ps_code)
static SIZE_T const char * filename
static BOOL init_test_context_(unsigned int line, struct test_context *context)
static SIZE_T const char const D3D_SHADER_MACRO * defines
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ** shader
#define trace_(file, line,...)
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
#define todo_wine_if(is_todo)
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl void winetest_pop_context(void)
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl winetest_push_context(const char *fmt,...) __WINE_PRINTF_ATTR(1
#define ERROR_FILE_NOT_FOUND
static struct test_info tests[]
D3D11_SHADER_VARIABLE_DESC desc
#define compare_float(got, exp)
#define create_file(name, size)
static IHTMLWindow2 * window
#define WS_OVERLAPPEDWINDOW
BOOL WINAPI AdjustWindowRect(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL)
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
BOOL WINAPI DestroyWindow(_In_ HWND)
static void quad(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3, GLuint pv)
#define D3DADAPTER_DEFAULT
#define D3DCREATE_HARDWARE_VERTEXPROCESSING
DWORD VertexShaderVersion
IDirect3DSurface9 * surface
IDirect3DDevice9 * device
ID3DInclude ID3DInclude_iface
Character const *const prefix
static HRESULT HRESULT_FROM_WIN32(unsigned int x)