ReactOS 0.4.17-dev-966-gf06eace
asm.c File Reference
#include "wine/test.h"
#include <d3d9types.h>
#include <d3dcommon.h>
#include <d3dcompiler.h>
Include dependency graph for asm.c:

Go to the source code of this file.

Classes

struct  shader_test
 
struct  D3DIncludeImpl
 

Macros

#define COBJMACROS
 
#define CONST_VTABLE
 
#define D3DXERR_INVALIDDATA   0x88760b59
 

Functions

static HRESULT (WINAPI *pD3DAssemble)(const void *data
 
static void dump_shader (DWORD *shader)
 
static void exec_tests (const char *name, struct shader_test tests[], unsigned int count)
 
static void preproc_test (void)
 
static void ps_1_1_test (void)
 
static void vs_1_1_test (void)
 
static void ps_1_3_test (void)
 
static void ps_1_4_test (void)
 
static void vs_2_0_test (void)
 
static void vs_2_x_test (void)
 
static void ps_2_0_test (void)
 
static void ps_2_x_test (void)
 
static void vs_3_0_test (void)
 
static void ps_3_0_test (void)
 
static void failure_test (void)
 
static HRESULT WINAPI testD3DInclude_open (ID3DInclude *iface, D3D_INCLUDE_TYPE include_type, const char *filename, const void *parent_data, const void **data, UINT *bytes)
 
static HRESULT WINAPI testD3DInclude_close (ID3DInclude *iface, const void *data)
 
static void assembleshader_test (void)
 
static void d3dpreprocess_test (void)
 
static void test_disassemble_shader (void)
 
 START_TEST (asm)
 

Variables

static SIZE_T datasize
 
static SIZE_T const char * filename
 
static SIZE_T const char const D3D_SHADER_MACRO * defines
 
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
 
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT flags
 
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ** shader
 
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ID3DBlob ** error_messages
 
static const struct ID3DIncludeVtbl D3DInclude_Vtbl
 
static const DWORD vs_2_0 []
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 18 of file asm.c.

◆ CONST_VTABLE

#define CONST_VTABLE

Definition at line 19 of file asm.c.

◆ D3DXERR_INVALIDDATA

#define D3DXERR_INVALIDDATA   0x88760b59

Definition at line 28 of file asm.c.

Function Documentation

◆ assembleshader_test()

static void assembleshader_test ( void  )
static

Definition at line 1524 of file asm.c.

1524 {
1525 static const char test1[] =
1526 {
1527 "vs.1.1\n"
1528 "mov DEF2, v0\n"
1529 };
1530 static const char testshader[] =
1531 {
1532 "#include \"incl.vsh\"\n"
1533 "mov REGISTER, v0\n"
1534 };
1535 static const D3D_SHADER_MACRO defines[] =
1536 {
1537 {
1538 "DEF1", "10 + 15"
1539 },
1540 {
1541 "DEF2", "r0"
1542 },
1543 {
1544 NULL, NULL
1545 }
1546 };
1547 HRESULT hr;
1549 struct D3DIncludeImpl include;
1550
1551 /* defines test */
1552 shader = NULL;
1553 messages = NULL;
1555 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
1556 if (messages)
1557 {
1558 trace("D3DAssemble messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
1559 ID3D10Blob_Release(messages);
1560 }
1561 if(shader) ID3D10Blob_Release(shader);
1562
1563 /* NULL messages test */
1564 shader = NULL;
1566 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
1567 if (shader)
1568 ID3D10Blob_Release(shader);
1569
1570 /* NULL shader test */
1571 messages = NULL;
1573 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
1574 if (messages)
1575 {
1576 trace("D3DAssemble messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
1577 ID3D10Blob_Release(messages);
1578 }
1579
1580 /* D3DInclude test */
1581 shader = NULL;
1582 messages = NULL;
1583 include.ID3DInclude_iface.lpVtbl = &D3DInclude_Vtbl;
1584 hr = pD3DAssemble(testshader, strlen(testshader), NULL, NULL,
1585 &include.ID3DInclude_iface, D3DCOMPILE_SKIP_VALIDATION, &shader, &messages);
1586 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
1587 if (messages)
1588 {
1589 trace("D3DAssemble messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
1590 ID3D10Blob_Release(messages);
1591 }
1592 if(shader) ID3D10Blob_Release(shader);
1593
1594 /* NULL shader tests */
1595 shader = NULL;
1596 messages = NULL;
1597 hr = pD3DAssemble(NULL, 0, NULL, NULL, NULL, D3DCOMPILE_SKIP_VALIDATION, &shader, &messages);
1598 ok(hr == D3DXERR_INVALIDDATA, "Got unexpected hr %#lx.\n", hr);
1599 if (messages)
1600 {
1601 trace("D3DAssemble messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
1602 ID3D10Blob_Release(messages);
1603 }
1604 if(shader) ID3D10Blob_Release(shader);
1605}
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define D3DCOMPILE_SKIP_VALIDATION
Definition: d3dcompiler.h:43
static const struct ID3DIncludeVtbl D3DInclude_Vtbl
Definition: asm.c:1514
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:31
#define D3DXERR_INVALIDDATA
Definition: asm.c:28
static SIZE_T const char const D3D_SHADER_MACRO * defines
Definition: asm.c:31
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude UINT ID3DBlob ** shader
Definition: asm.c:32
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
void test1()
Definition: ehthrow.cxx:277
GLuint shader
Definition: glext.h:6030
#define S_OK
Definition: intsafe.h:52

Referenced by START_TEST().

◆ d3dpreprocess_test()

static void d3dpreprocess_test ( void  )
static

Definition at line 1607 of file asm.c.

1608{
1609 static const char test1[] =
1610 {
1611 "vs.1.1\n"
1612 "mov DEF2, v0\n"
1613 };
1614 static const char quotation_marks_test[] =
1615 {
1616 "vs.1.1\n"
1617 "; ' comment\n"
1618 "; \" comment\n"
1619 "mov 0, v0\n"
1620 };
1621 static const char *include_test_shaders[] =
1622 {
1623 "#include \"incl.vsh\"\n"
1624 "mov REGISTER, v0\n",
1625
1626 "#include \"incl2.vsh\"\n"
1627 "mov REGISTER, v0\n",
1628
1629 "#include <incl.vsh>\n"
1630 "mov REGISTER, v0\n",
1631
1632 "#include <incl4.vsh>\n"
1633 "mov REGISTER, v0\n",
1634
1635 "#include \"includes/incl.vsh\"\n"
1636 "mov REGISTER, v0\n"
1637 };
1638 HRESULT hr;
1640 static const D3D_SHADER_MACRO defines[] =
1641 {
1642 {
1643 "DEF1", "10 + 15"
1644 },
1645 {
1646 "DEF2", "r0"
1647 },
1648 {
1649 NULL, NULL
1650 }
1651 };
1652 struct D3DIncludeImpl include;
1653 unsigned int i;
1654
1655 /* pDefines test */
1656 shader = NULL;
1657 messages = NULL;
1659 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
1660 if (messages)
1661 {
1662 trace("D3DPreprocess messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
1663 ID3D10Blob_Release(messages);
1664 }
1665 if (shader) ID3D10Blob_Release(shader);
1666
1667 /* NULL messages test */
1668 shader = NULL;
1670 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
1671 if (shader)
1672 ID3D10Blob_Release(shader);
1673
1674 /* NULL shader test */
1675 messages = NULL;
1677 todo_wine ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
1678 if (messages)
1679 {
1680 trace("D3DPreprocess messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
1681 ID3D10Blob_Release(messages);
1682 }
1683
1684 /* quotation marks test */
1685 shader = NULL;
1686 messages = NULL;
1687 hr = D3DPreprocess(quotation_marks_test, strlen(quotation_marks_test), NULL, NULL, NULL, &shader, &messages);
1688 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
1689 if (messages)
1690 {
1691 trace("D3DPreprocess messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
1692 ID3D10Blob_Release(messages);
1693 }
1694 if (shader) ID3D10Blob_Release(shader);
1695
1696 /* pInclude tests */
1697 include.ID3DInclude_iface.lpVtbl = &D3DInclude_Vtbl;
1698 for (i = 0; i < ARRAY_SIZE(include_test_shaders); ++i)
1699 {
1700 shader = NULL;
1701 messages = NULL;
1702 hr = D3DPreprocess(include_test_shaders[i], strlen(include_test_shaders[i]), NULL, NULL,
1703 &include.ID3DInclude_iface, &shader, &messages);
1704 ok(hr == S_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
1705 if (messages)
1706 {
1707 trace("D3DPreprocess messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
1708 ID3D10Blob_Release(messages);
1709 }
1710 if (shader) ID3D10Blob_Release(shader);
1711 }
1712
1713 /* NULL shader tests */
1714 shader = NULL;
1715 messages = NULL;
1717 ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
1718 if (messages)
1719 {
1720 trace("D3DPreprocess messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
1721 ID3D10Blob_Release(messages);
1722 }
1723 if (shader) ID3D10Blob_Release(shader);
1724}
#define ARRAY_SIZE(A)
Definition: main.h:20
HRESULT WINAPI D3DPreprocess(const void *data, SIZE_T size, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, ID3DBlob **shader, ID3DBlob **error_messages)
Definition: compiler.c:652
#define E_INVALIDARG
Definition: ddrawi.h:101
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
Definition: glfuncs.h:248
#define todo_wine
Definition: minitest.h:80

Referenced by START_TEST().

◆ dump_shader()

static void dump_shader ( DWORD *  shader)
static

Definition at line 39 of file asm.c.

39 {
40 unsigned int i = 0, j = 0;
41 do {
42 trace("0x%08lx ", shader[i]);
43 j++;
44 i++;
45 if(j == 6) trace("\n");
46 } while(shader[i - 1] != D3DSIO_END);
47 if(j != 6) trace("\n");
48}
@ D3DSIO_END
Definition: d3d8types.h:365
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
Definition: glfuncs.h:250

Referenced by exec_tests(), and failure_test().

◆ exec_tests()

static void exec_tests ( const char *  name,
struct shader_test  tests[],
unsigned int  count 
)
static

Definition at line 50 of file asm.c.

50 {
51 HRESULT hr;
52 DWORD *res;
53 unsigned int i, j;
54 BOOL diff;
56
57 for(i = 0; i < count; i++) {
58 /* D3DAssemble sets messages to 0 if there aren't error messages */
59 messages = NULL;
60 hr = pD3DAssemble(tests[i].text, strlen(tests[i].text), NULL, NULL,
62 ok(hr == S_OK, "Test %s, shader %u: D3DAssemble failed with error %#lx - %ld.\n", name, i, hr, hr & 0xffff);
63 if(messages) {
64 trace("D3DAssemble messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
65 ID3D10Blob_Release(messages);
66 }
67 if(FAILED(hr)) continue;
68
69 j = 0;
70 diff = FALSE;
71 res = ID3D10Blob_GetBufferPointer(shader);
72 while(res[j] != D3DSIO_END && tests[i].bytes[j] != D3DSIO_END) {
73 if(res[j] != tests[i].bytes[j]) diff = TRUE;
74 j++;
75 };
76 /* Both must have an end token */
77 if(res[j] != tests[i].bytes[j]) diff = TRUE;
78
79 if(diff) {
80 ok(FALSE, "Test %s, shader %d: Generated code differs\n", name, i);
82 }
83 ID3D10Blob_Release(shader);
84 }
85}
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
static void dump_shader(DWORD *shader)
Definition: asm.c:39
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
const WCHAR * text
Definition: package.c:1826
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint res
Definition: glext.h:9613
#define FAILED(hr)
Definition: intsafe.h:51
static struct test_info tests[]
Definition: name.c:39

Referenced by preproc_test(), ps_1_1_test(), ps_1_3_test(), ps_1_4_test(), ps_2_0_test(), ps_2_x_test(), ps_3_0_test(), vs_1_1_test(), vs_2_0_test(), vs_2_x_test(), and vs_3_0_test().

◆ failure_test()

static void failure_test ( void  )
static

Definition at line 1272 of file asm.c.

1272 {
1273 const char * tests[] = {
1274 /* shader 0: instruction modifier not allowed */
1275 "ps_3_0\n"
1276 "dcl_2d s2\n"
1277 "texldd_x2 r0, v1, s2, v3, v4\n",
1278 /* shader 1: coissue not supported in vertex shaders */
1279 "vs.1.1\r\n"
1280 "add r0.rgb, r0, r1\n"
1281 "+add r0.a, r0, r2\n",
1282 /* shader 2: coissue not supported in pixel shader version >= 2.0 */
1283 "ps_2_0\n"
1284 "texld r0, t0, s0\n"
1285 "add r0.rgb, r0, r1\n"
1286 "+add r0.a, r0, v1\n",
1287 /* shader 3: predicates not supported in vertex shader < 2.0 */
1288 "vs_1_1\n"
1289 "(p0) add r0, r0, v0\n",
1290 /* shader 4: register a0 doesn't exist in pixel shaders */
1291 "ps_3_0\n"
1292 "mov r0, v[ a0 + 12 ]\n",
1293 /* shader 5: s0 doesn't exist in vs_1_1 */
1294 "vs_1_1\n"
1295 "mov r0, s0\n",
1296 /* shader 6: aL is a scalar register, no swizzles allowed */
1297 "ps_3_0\n"
1298 "mov r0, v[ aL.x + 12 ]\n",
1299 /* shader 7: tn doesn't exist in ps_3_0 */
1300 "ps_3_0\n"
1301 "dcl_2d s2\n"
1302 "texldd r0, t1, s2, v3, v4\n",
1303 /* shader 8: two shift modifiers */
1304 "ps_1_3\n"
1305 "mov_x2_x2 r0, r1\n",
1306 /* shader 9: too many source registers for mov instruction */
1307 "vs_1_1\n"
1308 "mov r0, r1, r2\n",
1309 /* shader 10: invalid combination of negate and divide modifiers */
1310 "ps_1_4\n"
1311 "texld r5, -r2_dz\n",
1312 /* shader 11: complement modifier not allowed in >= PS 2 */
1313 "ps_2_0\n"
1314 "mov r2, 1 - r0\n",
1315 /* shader 12: invalid modifier */
1316 "vs_3_0\n"
1317 "mov r2, 2 - r0\n",
1318 /* shader 13: float value in relative addressing */
1319 "vs_3_0\n"
1320 "mov r2, c[ aL + 3.4 ]\n",
1321 /* shader 14: complement modifier not available in VS */
1322 "vs_3_0\n"
1323 "mov r2, 1 - r1\n",
1324 /* shader 15: _x2 modifier not available in VS */
1325 "vs_1_1\n"
1326 "mov r2, r1_x2\n",
1327 /* shader 16: _abs modifier not available in < VS 3.0 */
1328 "vs_1_1\n"
1329 "mov r2, r1_abs\n",
1330 /* shader 17: _x2 modifier not available in >= PS 2.0 */
1331 "ps_2_0\n"
1332 "mov r0, r1_x2\n",
1333 /* shader 18: wrong swizzle */
1334 "vs_2_0\n"
1335 "mov r0, r1.abcd\n",
1336 /* shader 19: wrong swizzle */
1337 "vs_2_0\n"
1338 "mov r0, r1.xyzwx\n",
1339 /* shader 20: wrong swizzle */
1340 "vs_2_0\n"
1341 "mov r0, r1.\n",
1342 /* shader 21: invalid writemask */
1343 "vs_2_0\n"
1344 "mov r0.xxyz, r1\n",
1345 /* shader 22: register r5 doesn't exist in PS < 1.4 */
1346 "ps_1_3\n"
1347 "mov r5, r0\n",
1348 /* shader 23: can't declare output registers in a pixel shader */
1349 "ps_3_0\n"
1350 "dcl_positiont o0\n",
1351 /* shader 24: _pp instruction modifier not allowed in vertex shaders */
1352 "vs_3_0\n"
1353 "add_pp r0, r0, r1\n",
1354 /* shader 25: _x4 instruction modified not allowed in > ps_1_x */
1355 "ps_3_0\n"
1356 "add_x4 r0, r0, r1\n",
1357 /* shader 26: there aren't oCx registers in ps_1_x */
1358 "ps_1_3\n"
1359 "add oC0, r0, r1\n",
1360 /* shader 27: oC3 is the max in >= ps_2_0 */
1361 "ps_3_0\n"
1362 "add oC4, r0, r1\n",
1363 /* shader 28: register v17 doesn't exist */
1364 "vs_3_0\n"
1365 "add r0, r0, v17\n",
1366 /* shader 29: register o13 doesn't exist */
1367 "vs_3_0\n"
1368 "add o13, r0, r1\n",
1369 /* shader 30: label > 2047 not allowed */
1370 "vs_3_0\n"
1371 "call l2048\n",
1372 /* shader 31: s20 register does not exist */
1373 "ps_3_0\n"
1374 "texld r0, r1, s20\n",
1375 /* shader 32: t5 not allowed in ps_1_3 */
1376 "ps_1_3\n"
1377 "tex t5\n",
1378 /* shader 33: no temporary registers relative addressing */
1379 "vs_3_0\n"
1380 "add r0, r0[ a0.x ], r1\n",
1381 /* shader 34: no input registers relative addressing in vs_2_0 */
1382 "vs_2_0\n"
1383 "add r0, v[ a0.x ], r1\n",
1384 /* shader 35: no aL register in ps_2_0 */
1385 "ps_2_0\n"
1386 "add r0, v[ aL ], r1\n",
1387 /* shader 36: no relative addressing in ps_2_0 */
1388 "ps_2_0\n"
1389 "add r0, v[ r0 ], r1\n",
1390 /* shader 37: no a0 register in ps_3_0 */
1391 "ps_3_0\n"
1392 "add r0, v[ a0.x ], r1\n",
1393 /* shader 38: only a0.x accepted in vs_1_1 */
1394 "vs_1_1\n"
1395 "mov r0, c0[ a0 ]\n",
1396 /* shader 39: invalid modifier for dcl instruction */
1397 "ps_3_0\n"
1398 "dcl_texcoord0_sat v0\n",
1399 /* shader 40: shift not allowed */
1400 "ps_3_0\n"
1401 "dcl_texcoord0_x2 v0\n",
1402 /* shader 41: no modifier allowed with dcl instruction in vs */
1403 "vs_3_0\n"
1404 "dcl_texcoord0_centroid v0\n",
1405 /* shader 42: no modifiers with vs dcl sampler instruction */
1406 "vs_3_0\n"
1407 "dcl_2d_pp s0\n",
1408 /* shader 43: */
1409 "ps_2_0\n"
1410 "texm3x3vspec t3, t0\n",
1411 /* shader 44: expression in defi not allowed */
1412 "vs_2_0\n"
1413 "defi i0, -1 - 1, 1, 10, 0\n"
1414 "defi i1, 0, 40, 30, 10\n",
1415 /* shader 45: '-' not allowed inside relative addressing operands */
1416 "vs.3.0\n"
1417 "add r0, v0[aL - 3 + 5], r2\n",
1418 /* shader 46: float constants in defi */
1419 "vs_2_0\n"
1420 "defi i0, 1.0, 1.1, 10.2, 0.3\n"
1421 "defi i1, 0, 40, 30, 10\n",
1422 /* shader 47: double '-' sign */
1423 "vs.3.0\n"
1424 "defi c0, -1, --1, 0, 0\n",
1425 };
1426 HRESULT hr;
1427 unsigned int i;
1429
1430 for(i = 0; i < ARRAY_SIZE(tests); i++)
1431 {
1432 shader = NULL;
1433 messages = NULL;
1435 ok(hr == D3DXERR_INVALIDDATA, "Test %u: Got unexpected hr %#lx.\n", i, hr);
1436 if (messages)
1437 {
1438 trace("D3DAssemble messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
1439 ID3D10Blob_Release(messages);
1440 }
1441 if(shader) {
1442 DWORD *res = ID3D10Blob_GetBufferPointer(shader);
1444 ID3D10Blob_Release(shader);
1445 }
1446 }
1447}

Referenced by START_TEST().

◆ HRESULT()

static HRESULT ( WINAPI *  pD3DAssemble) const
static

◆ preproc_test()

static void preproc_test ( void  )
static

Definition at line 87 of file asm.c.

87 {
88 struct shader_test tests[] = {
89 { /* shader 0 */
90 "vs.1.1\r\n"
91 "//some comments\r\n"
92 "//other comments\n"
93 "; yet another comment\r\n"
94 "add r0, r0, r1\n",
95 {0xfffe0101, 0x00000002, 0x800f0000, 0x80e40000, 0x80e40001, 0x0000ffff}
96 },
97 { /* shader 1 */
98 "#line 1 \"vertex.vsh\"\n"
99 "vs.1.1\n",
100 {0xfffe0101, 0x0000ffff}
101 },
102 { /* shader 2 */
103 "#define REG 1 + 2 +\\\n"
104 "3 + 4\n"
105 "vs.1.1\n"
106 "mov r0, c0[ REG ]\n",
107 {0xfffe0101, 0x00000001, 0x800f0000, 0xa0e4000a, 0x0000ffff}
108 },
109 };
110
111 exec_tests("preproc", tests, ARRAY_SIZE(tests));
112}
static void exec_tests(const char *name, struct shader_test tests[], unsigned int count)
Definition: asm.c:50

Referenced by START_TEST().

◆ ps_1_1_test()

static void ps_1_1_test ( void  )
static

Definition at line 114 of file asm.c.

114 {
115 struct shader_test tests[] = {
116 { /* shader 0 */
117 "ps.1.1\r\n"
118 "tex t0\r\n"
119 "add r0.rgb, r0, r1\r\n"
120 "+mov r0.a, t0\r\n",
121 {0xffff0101, 0x00000042, 0xb00f0000, 0x00000002, 0x80070000, 0x80e40000,
122 0x80e40001, 0x40000001, 0x80080000, 0xb0e40000, 0x0000ffff}
123 },
124 { /* shader 1 */
125 "ps.1.1\n"
126 "mov_d4 r0, r1\n",
127 {0xffff0101, 0x00000001, 0x8e0f0000, 0x80e40001, 0x0000ffff}
128 },
129 { /* shader 2 */
130 "ps_1_1\n"
131 "def c2, 0, 0., 0, 0.\n",
132 {0xffff0101, 0x00000051, 0xa00f0002, 0x00000000, 0x00000000, 0x00000000,
133 0x00000000, 0x0000ffff}
134 },
135 };
136
137 exec_tests("ps_1_1", tests, ARRAY_SIZE(tests));
138}

Referenced by START_TEST().

◆ ps_1_3_test()

static void ps_1_3_test ( void  )
static

Definition at line 283 of file asm.c.

283 {
284 struct shader_test tests[] = {
285 /* Basic instruction tests */
286 { /* shader 0 */
287 "ps_1_3\n"
288 "mov r0, r1\n",
289 {0xffff0103, 0x00000001, 0x800f0000, 0x80e40001, 0x0000ffff}
290 },
291 { /* shader 1 */
292 "ps_1_3\n"
293 "add r0, r1, r0\n",
294 {0xffff0103, 0x00000002, 0x800f0000, 0x80e40001, 0x80e40000, 0x0000ffff}
295 },
296 /* Color interpolator tests */
297 { /* shader 2 */
298 "ps_1_3\n"
299 "mov r0, v0\n",
300 {0xffff0103, 0x00000001, 0x800f0000, 0x90e40000, 0x0000ffff}
301 },
302 { /* shader 3 */
303 "ps_1_3\n"
304 "mov r0, v1\n",
305 {0xffff0103, 0x00000001, 0x800f0000, 0x90e40001, 0x0000ffff}
306 },
307 /* Texture sampling instructions */
308 { /* shader 4 */
309 "ps_1_3\n"
310 "tex t0\n",
311 {0xffff0103, 0x00000042, 0xb00f0000, 0x0000ffff}
312 },
313 { /* shader 5 */
314 "ps_1_3\n"
315 "tex t0\n"
316 "texreg2ar t1, t0\n",
317 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000045, 0xb00f0001, 0xb0e40000,
318 0x0000ffff}
319 },
320 { /* shader 6 */
321 "ps_1_3\n"
322 "tex t0\n"
323 "texreg2gb t1, t0\n",
324 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000046, 0xb00f0001, 0xb0e40000,
325 0x0000ffff}
326 },
327 { /* shader 7 */
328 "ps_1_3\n"
329 "tex t0\n"
330 "texreg2rgb t1, t0\n",
331 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000052, 0xb00f0001, 0xb0e40000,
332 0x0000ffff}
333 },
334 { /* shader 8 */
335 "ps_1_3\n"
336 "cnd r0, r1, r0, v0\n",
337 {0xffff0103, 0x00000050, 0x800f0000, 0x80e40001, 0x80e40000, 0x90e40000,
338 0x0000ffff}
339 },
340 { /* shader 9 */
341 "ps_1_3\n"
342 "cmp r0, r1, r0, v0\n",
343 {0xffff0103, 0x00000058, 0x800f0000, 0x80e40001, 0x80e40000, 0x90e40000,
344 0x0000ffff}
345 },
346 { /* shader 10 */
347 "ps_1_3\n"
348 "texkill t0\n",
349 {0xffff0103, 0x00000041, 0xb00f0000, 0x0000ffff}
350 },
351 { /* shader 11 */
352 "ps_1_3\n"
353 "tex t0\n"
354 "texm3x2pad t1, t0\n"
355 "texm3x2tex t2, t0\n",
356 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000047, 0xb00f0001, 0xb0e40000,
357 0x00000048, 0xb00f0002, 0xb0e40000, 0x0000ffff}
358 },
359 { /* shader 12 */
360 "ps_1_3\n"
361 "tex t0\n"
362 "texm3x2pad t1, t0\n"
363 "texm3x2depth t2, t0\n",
364 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000047, 0xb00f0001, 0xb0e40000,
365 0x00000054, 0xb00f0002, 0xb0e40000, 0x0000ffff}
366 },
367 { /* shader 13 */
368 "ps_1_3\n"
369 "tex t0\n"
370 "texbem t1, t0\n",
371 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000043, 0xb00f0001, 0xb0e40000,
372 0x0000ffff}
373 },
374 { /* shader 14 */
375 "ps_1_3\n"
376 "tex t0\n"
377 "texbeml t1, t0\n",
378 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000044, 0xb00f0001, 0xb0e40000,
379 0x0000ffff}
380 },
381 { /* shader 15 */
382 "ps_1_3\n"
383 "tex t0\n"
384 "texdp3tex t1, t0\n",
385 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000053, 0xb00f0001, 0xb0e40000,
386 0x0000ffff}
387 },
388 { /* shader 16 */
389 "ps_1_3\n"
390 "tex t0\n"
391 "texdp3 t1, t0\n",
392 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000055, 0xb00f0001, 0xb0e40000,
393 0x0000ffff}
394 },
395 { /* shader 17 */
396 "ps_1_3\n"
397 "tex t0\n"
398 "texm3x3pad t1, t0\n"
399 "texm3x3pad t2, t0\n"
400 "texm3x3tex t3, t0\n",
401 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000049, 0xb00f0001, 0xb0e40000,
402 0x00000049, 0xb00f0002, 0xb0e40000, 0x0000004a, 0xb00f0003, 0xb0e40000,
403 0x0000ffff}
404 },
405 { /* shader 18 */
406 "ps_1_3\n"
407 "tex t0\n"
408 "texm3x3pad t1, t0\n"
409 "texm3x3pad t2, t0\n"
410 "texm3x3 t3, t0\n",
411 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000049, 0xb00f0001, 0xb0e40000,
412 0x00000049, 0xb00f0002, 0xb0e40000, 0x00000056, 0xb00f0003, 0xb0e40000,
413 0x0000ffff}
414 },
415 { /* shader 19 */
416 "ps_1_3\n"
417 "tex t0\n"
418 "texm3x3pad t1, t0\n"
419 "texm3x3pad t2, t0\n"
420 "texm3x3spec t3, t0, c0\n",
421 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000049, 0xb00f0001, 0xb0e40000,
422 0x00000049, 0xb00f0002, 0xb0e40000, 0x0000004c, 0xb00f0003, 0xb0e40000,
423 0xa0e40000, 0x0000ffff}
424 },
425 { /* shader 20 */
426 "ps_1_3\n"
427 "tex t0\n"
428 "texm3x3pad t1, t0\n"
429 "texm3x3pad t2, t0\n"
430 "texm3x3vspec t3, t0\n",
431 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000049, 0xb00f0001, 0xb0e40000,
432 0x00000049, 0xb00f0002, 0xb0e40000, 0x0000004d, 0xb00f0003, 0xb0e40000,
433 0x0000ffff}
434 },
435 { /* shader 21 */
436 "ps_1_3\n"
437 "texcoord t0\n",
438 {0xffff0103, 0x00000040, 0xb00f0000, 0x0000ffff}
439 },
440 /* Modifiers, shifts */
441 { /* shader 22 */
442 "ps_1_3\n"
443 "mov_x2_sat r0, 1 - r1\n",
444 {0xffff0103, 0x00000001, 0x811f0000, 0x86e40001, 0x0000ffff}
445 },
446 { /* shader 23 */
447 "ps_1_3\n"
448 "mov_d8 r0, -r1\n",
449 {0xffff0103, 0x00000001, 0x8d0f0000, 0x81e40001, 0x0000ffff}
450 },
451 { /* shader 24 */
452 "ps_1_3\n"
453 "mov_sat r0, r1_bx2\n",
454 {0xffff0103, 0x00000001, 0x801f0000, 0x84e40001, 0x0000ffff}
455 },
456 { /* shader 25 */
457 "ps_1_3\n"
458 "mov_sat r0, r1_bias\n",
459 {0xffff0103, 0x00000001, 0x801f0000, 0x82e40001, 0x0000ffff}
460 },
461 { /* shader 26 */
462 "ps_1_3\n"
463 "mov_sat r0, -r1_bias\n",
464 {0xffff0103, 0x00000001, 0x801f0000, 0x83e40001, 0x0000ffff}
465 },
466 { /* shader 27 */
467 "ps_1_3\n"
468 "mov_sat r0, -r1_bx2\n",
469 {0xffff0103, 0x00000001, 0x801f0000, 0x85e40001, 0x0000ffff}
470 },
471 { /* shader 28 */
472 "ps_1_3\n"
473 "mov_sat r0, -r1_x2\n",
474 {0xffff0103, 0x00000001, 0x801f0000, 0x88e40001, 0x0000ffff}
475 },
476 { /* shader 29 */
477 "ps_1_3\n"
478 "mov_x4_sat r0.a, -r1_bx2.a\n",
479 {0xffff0103, 0x00000001, 0x82180000, 0x85ff0001, 0x0000ffff}
480 },
481 { /* shader 30 */
482 "ps_1_3\n"
483 "texcoord_x2 t0\n",
484 {0xffff0103, 0x00000040, 0xb10f0000, 0x0000ffff}
485 },
486 { /* shader 31 */
487 "ps_1_3\n"
488 "tex_x2 t0\n",
489 {0xffff0103, 0x00000042, 0xb10f0000, 0x0000ffff}
490 },
491 { /* shader 32 */
492 "ps_1_3\n"
493 "texreg2ar_x4 t0, t1\n",
494 {0xffff0103, 0x00000045, 0xb20f0000, 0xb0e40001, 0x0000ffff}
495 },
496 { /* shader 33 */
497 "ps_1_3\n"
498 "texbem_d4 t1, t0\n",
499 {0xffff0103, 0x00000043, 0xbe0f0001, 0xb0e40000, 0x0000ffff}
500 },
501 { /* shader 34 */
502 "ps_1_3\n"
503 "tex t0\n"
504 "texm3x3pad_x2 t1, t0\n"
505 "texm3x3pad_x2 t2, t0\n"
506 "texm3x3tex_x2 t3, t0\n",
507 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000049, 0xb10f0001, 0xb0e40000,
508 0x00000049, 0xb10f0002, 0xb0e40000, 0x0000004a, 0xb10f0003, 0xb0e40000,
509 0x0000ffff}
510 },
511 { /* shader 35 */
512 "ps.1.3\n"
513 "tex t0\n"
514 "texdp3tex_x8 t1, t0\n",
515 {0xffff0103, 0x00000042, 0xb00f0000, 0x00000053, 0xb30f0001, 0xb0e40000,
516 0x0000ffff}
517 },
518 };
519
520 exec_tests("ps_1_3", tests, ARRAY_SIZE(tests));
521}

Referenced by START_TEST().

◆ ps_1_4_test()

static void ps_1_4_test ( void  )
static

Definition at line 523 of file asm.c.

523 {
524 struct shader_test tests[] = {
525 /* Basic instruction tests */
526 { /* shader 0 */
527 "ps_1_4\n"
528 "mov r0, r1\n",
529 {0xffff0104, 0x00000001, 0x800f0000, 0x80e40001, 0x0000ffff}
530 },
531 { /* shader 1 */
532 "ps_1_4\n"
533 "mov r0, r5\n",
534 {0xffff0104, 0x00000001, 0x800f0000, 0x80e40005, 0x0000ffff}
535 },
536 { /* shader 2 */
537 "ps_1_4\n"
538 "mov r0, c7\n",
539 {0xffff0104, 0x00000001, 0x800f0000, 0xa0e40007, 0x0000ffff}
540 },
541 { /* shader 3 */
542 "ps_1_4\n"
543 "mov r0, v1\n",
544 {0xffff0104, 0x00000001, 0x800f0000, 0x90e40001, 0x0000ffff}
545 },
546 { /* shader 4 */
547 "ps_1_4\n"
548 "phase\n",
549 {0xffff0104, 0x0000fffd, 0x0000ffff}
550 },
551 { /* shader 5 */
552 "ps_1_4\n"
553 "texcrd r0, t0\n",
554 {0xffff0104, 0x00000040, 0x800f0000, 0xb0e40000, 0x0000ffff}
555 },
556 { /* shader 6 */
557 "ps_1_4\n"
558 "texcrd r4, t3\n",
559 {0xffff0104, 0x00000040, 0x800f0004, 0xb0e40003, 0x0000ffff}
560 },
561 { /* shader 7 */
562 "ps_1_4\n"
563 "texcrd_sat r4, t3\n",
564 {0xffff0104, 0x00000040, 0x801f0004, 0xb0e40003, 0x0000ffff}
565 },
566 { /* shader 8 */
567 "ps_1_4\n"
568 "texld r0, t0\n",
569 {0xffff0104, 0x00000042, 0x800f0000, 0xb0e40000, 0x0000ffff}
570 },
571 { /* shader 9 */
572 "ps_1_4\n"
573 "texld r1, t4\n",
574 {0xffff0104, 0x00000042, 0x800f0001, 0xb0e40004, 0x0000ffff}
575 },
576 { /* shader 10 */
577 "ps_1_4\n"
578 "texld r5, r0\n",
579 {0xffff0104, 0x00000042, 0x800f0005, 0x80e40000, 0x0000ffff}
580 },
581 { /* shader 11 */
582 "ps_1_4\n"
583 "texld r5, c0\n", /* Assembly succeeds, validation fails */
584 {0xffff0104, 0x00000042, 0x800f0005, 0xa0e40000, 0x0000ffff}
585 },
586 { /* shader 12 */
587 "ps_1_4\n"
588 "texld r5, r2_dz\n",
589 {0xffff0104, 0x00000042, 0x800f0005, 0x89e40002, 0x0000ffff}
590 },
591 { /* shader 13 */
592 "ps_1_4\n"
593 "bem r1.rg, c0, r0\n",
594 {0xffff0104, 0x00000059, 0x80030001, 0xa0e40000, 0x80e40000, 0x0000ffff}
595 },
596 { /* shader 14 */
597 "ps_1_4\n"
598 "texdepth r5\n",
599 {0xffff0104, 0x00000057, 0x800f0005, 0x0000ffff}
600 },
601 { /* shader 15 */
602 "ps_1_4\n"
603 "add r0, r1, r2_bx2\n",
604 {0xffff0104, 0x00000002, 0x800f0000, 0x80e40001, 0x84e40002, 0x0000ffff}
605 },
606 { /* shader 16 */
607 "ps_1_4\n"
608 "add_x4 r0, r1, r2\n",
609 {0xffff0104, 0x00000002, 0x820f0000, 0x80e40001, 0x80e40002, 0x0000ffff}
610 },
611 { /* shader 17 */
612 "ps_1_4\n"
613 "add r0.rgb, r1, r2\n"
614 "+add r0.a, r1, r2\n",
615 {0xffff0104, 0x00000002, 0x80070000, 0x80e40001, 0x80e40002, 0x40000002,
616 0x80080000, 0x80e40001, 0x80e40002, 0x0000ffff}
617 },
618 { /* shader 18 */
619 "ps_1_4\n"
620 "texdepth_x2 r5\n",
621 {0xffff0104, 0x00000057, 0x810f0005, 0x0000ffff}
622 },
623 { /* shader 18 */
624 "ps.1.4\n"
625 "bem_d2 r1, c0, r0\n",
626 {0xffff0104, 0x00000059, 0x8f0f0001, 0xa0e40000, 0x80e40000, 0x0000ffff}
627 },
628 };
629
630 exec_tests("ps_1_4", tests, ARRAY_SIZE(tests));
631}

Referenced by START_TEST().

◆ ps_2_0_test()

static void ps_2_0_test ( void  )
static

Definition at line 885 of file asm.c.

885 {
886 struct shader_test tests[] = {
887 { /* shader 0 */
888 "ps_2_0\n"
889 "dcl_2d s0\n",
890 {0xffff0200, 0x0200001f, 0x90000000, 0xa00f0800, 0x0000ffff}
891 },
892 { /* shader 1 */
893 "ps_2_0\n"
894 "dcl_cube s0\n",
895 {0xffff0200, 0x0200001f, 0x98000000, 0xa00f0800, 0x0000ffff}
896 },
897 { /* shader 2 */
898 "ps_2_0\n"
899 "dcl_volume s0\n",
900 {0xffff0200, 0x0200001f, 0xa0000000, 0xa00f0800, 0x0000ffff}
901 },
902 { /* shader 3 */
903 "ps_2_0\n"
904 "dcl_volume s0\n"
905 "dcl_cube s1\n"
906 "dcl_2d s2\n",
907 {0xffff0200, 0x0200001f, 0xa0000000, 0xa00f0800, 0x0200001f, 0x98000000,
908 0xa00f0801, 0x0200001f, 0x90000000, 0xa00f0802, 0x0000ffff}
909 },
910 { /* shader 4 */
911 "ps_2_0\n"
912 "mov r0, t0\n",
913 {0xffff0200, 0x02000001, 0x800f0000, 0xb0e40000, 0x0000ffff}
914 },
915 { /* shader 5 */
916 "ps_2_0\n"
917 "dcl_2d s2\n"
918 "texld r0, t1, s2\n",
919 {0xffff0200, 0x0200001f, 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000,
920 0xb0e40001, 0xa0e40802, 0x0000ffff}
921 },
922 { /* shader 6 */
923 "ps_2_0\n"
924 "texkill t0\n",
925 {0xffff0200, 0x01000041, 0xb00f0000, 0x0000ffff}
926 },
927 { /* shader 7 */
928 "ps_2_0\n"
929 "mov oC0, c0\n"
930 "mov oC1, c1\n",
931 {0xffff0200, 0x02000001, 0x800f0800, 0xa0e40000, 0x02000001, 0x800f0801,
932 0xa0e40001, 0x0000ffff}
933 },
934 { /* shader 8 */
935 "ps_2_0\n"
936 "mov oDepth, c0.x\n",
937 {0xffff0200, 0x02000001, 0x900f0800, 0xa0000000, 0x0000ffff}
938 },
939 { /* shader 9 */
940 "ps_2_0\n"
941 "dcl_2d s2\n"
942 "texldp r0, t1, s2\n",
943 {0xffff0200, 0x0200001f, 0x90000000, 0xa00f0802, 0x03010042, 0x800f0000,
944 0xb0e40001, 0xa0e40802, 0x0000ffff}
945 },
946 { /* shader 10 */
947 "ps.2.0\n"
948 "dcl_2d s2\n"
949 "texldb r0, t1, s2\n",
950 {0xffff0200, 0x0200001f, 0x90000000, 0xa00f0802, 0x03020042, 0x800f0000,
951 0xb0e40001, 0xa0e40802, 0x0000ffff}
952 },
953 };
954
955 exec_tests("ps_2_0", tests, ARRAY_SIZE(tests));
956}

Referenced by START_TEST().

◆ ps_2_x_test()

static void ps_2_x_test ( void  )
static

Definition at line 958 of file asm.c.

958 {
959 struct shader_test tests[] = {
960 /* defb and defi are not supposed to work in ps_2_0 (even if defb actually works in ps_2_0 with native) */
961 { /* shader 0 */
962 "ps_2_x\n"
963 "defb b0, true\n"
964 "defb b1, false\n",
965 {0xffff0201, 0x0200002f, 0xe00f0800, 0x00000001, 0x0200002f, 0xe00f0801,
966 0x00000000, 0x0000ffff}
967 },
968 { /* shader 1 */
969 "ps_2_x\n"
970 "defi i0, -1, 1, 10, 0\n"
971 "defi i1, 0, 40, 30, 10\n",
972 {0xffff0201, 0x05000030, 0xf00f0000, 0xffffffff, 0x00000001, 0x0000000a,
973 0x00000000, 0x05000030, 0xf00f0001, 0x00000000, 0x00000028, 0x0000001e,
974 0x0000000a, 0x0000ffff},
975 },
976 { /* shader 2 */
977 "ps_2_x\n"
978 "dsx r0, r0\n",
979 {0xffff0201, 0x0200005b, 0x800f0000, 0x80e40000, 0x0000ffff}
980 },
981 { /* shader 3 */
982 "ps_2_x\n"
983 "dsy r0, r0\n",
984 {0xffff0201, 0x0200005c, 0x800f0000, 0x80e40000, 0x0000ffff}
985 },
986 { /* shader 4 */
987 "ps_2_x\n"
988 "dcl_2d s2\n"
989 "texldd r0, v1, s2, r3, r4\n",
990 {0xffff0201, 0x0200001f, 0x90000000, 0xa00f0802, 0x0500005d, 0x800f0000,
991 0x90e40001, 0xa0e40802, 0x80e40003, 0x80e40004, 0x0000ffff}
992 },
993 /* Static flow control tests */
994 { /* shader 5 */
995 "ps_2_x\n"
996 "call l0\n"
997 "ret\n"
998 "label l0\n"
999 "ret\n",
1000 {0xffff0201, 0x01000019, 0xa0e41000, 0x0000001c, 0x0100001e, 0xa0e41000,
1001 0x0000001c, 0x0000ffff}
1002 },
1003 { /* shader 6 */
1004 "ps_2_x\n"
1005 "callnz l0, b0\n"
1006 "ret\n"
1007 "label l0\n"
1008 "ret\n",
1009 {0xffff0201, 0x0200001a, 0xa0e41000, 0xe0e40800, 0x0000001c, 0x0100001e,
1010 0xa0e41000, 0x0000001c, 0x0000ffff}
1011 },
1012 { /* shader 7 */
1013 "ps_2_x\n"
1014 "callnz l0, !b0\n"
1015 "ret\n"
1016 "label l0\n"
1017 "ret\n",
1018 {0xffff0201, 0x0200001a, 0xa0e41000, 0xede40800, 0x0000001c, 0x0100001e,
1019 0xa0e41000, 0x0000001c, 0x0000ffff}
1020 },
1021 { /* shader 8 */
1022 "ps_2_x\n"
1023 "if !b0\n"
1024 "else\n"
1025 "endif\n",
1026 {0xffff0201, 0x01000028, 0xede40800, 0x0000002a, 0x0000002b, 0x0000ffff}
1027 },
1028 /* Dynamic flow control tests */
1029 { /* shader 9 */
1030 "ps_2_x\n"
1031 "rep i0\n"
1032 "break\n"
1033 "endrep\n",
1034 {0xffff0201, 0x01000026, 0xf0e40000, 0x0000002c, 0x00000027, 0x0000ffff}
1035 },
1036 { /* shader 10 */
1037 "ps_2_x\n"
1038 "if_ge r0, r1\n"
1039 "endif\n",
1040 {0xffff0201, 0x02030029, 0x80e40000, 0x80e40001, 0x0000002b, 0x0000ffff}
1041 },
1042 { /* shader 11 */
1043 "ps_2_x\n"
1044 "rep i0\n"
1045 "break_ne r0, r1\n"
1046 "endrep",
1047 {0xffff0201, 0x01000026, 0xf0e40000, 0x0205002d, 0x80e40000, 0x80e40001,
1048 0x00000027, 0x0000ffff}
1049 },
1050 /* Predicates */
1051 { /* shader 12 */
1052 "ps_2_x\n"
1053 "setp_gt p0, r0, r1\n"
1054 "(!p0) add r2, r2, r3\n",
1055 {0xffff0201, 0x0301005e, 0xb00f1000, 0x80e40000, 0x80e40001, 0x14000002,
1056 0x800f0002, 0xbde41000, 0x80e40002, 0x80e40003, 0x0000ffff}
1057 },
1058 { /* shader 13 */
1059 "ps_2_x\n"
1060 "if p0.x\n"
1061 "else\n"
1062 "endif\n",
1063 {0xffff0201, 0x01000028, 0xb0001000, 0x0000002a, 0x0000002b, 0x0000ffff}
1064 },
1065 { /* shader 14 */
1066 "ps_2_x\n"
1067 "callnz l0, !p0.z\n"
1068 "ret\n"
1069 "label l0\n"
1070 "ret\n",
1071 {0xffff0201, 0x0200001a, 0xa0e41000, 0xbdaa1000, 0x0000001c,
1072 0x0100001e, 0xa0e41000, 0x0000001c, 0x0000ffff}
1073 },
1074 { /* shader 15 */
1075 "ps_2_x\n"
1076 "rep i0\n"
1077 "breakp p0.w\n"
1078 "endrep\n",
1079 {0xffff0201, 0x01000026, 0xf0e40000, 0x01000060, 0xb0ff1000,
1080 0x00000027, 0x0000ffff}
1081 },
1082 { /* shader 16 */
1083 "ps.2.x\n"
1084 "call l2047\n"
1085 "ret\n"
1086 "label l2047\n"
1087 "ret\n",
1088 {0xffff0201, 0x01000019, 0xa0e417ff, 0x0000001c, 0x0100001e, 0xa0e417ff,
1089 0x0000001c, 0x0000ffff}
1090 },
1091 };
1092
1093 exec_tests("ps_2_x", tests, ARRAY_SIZE(tests));
1094}

Referenced by START_TEST().

◆ ps_3_0_test()

static void ps_3_0_test ( void  )
static

Definition at line 1186 of file asm.c.

1186 {
1187 struct shader_test tests[] = {
1188 { /* shader 0 */
1189 "ps_3_0\n"
1190 "mov r0, c0\n",
1191 {0xffff0300, 0x02000001, 0x800f0000, 0xa0e40000, 0x0000ffff}
1192 },
1193 { /* shader 1 */
1194 "ps_3_0\n"
1195 "dcl_normal5 v0\n",
1196 {0xffff0300, 0x0200001f, 0x80050003, 0x900f0000, 0x0000ffff}
1197 },
1198 { /* shader 2 */
1199 "ps_3_0\n"
1200 "mov r0, vPos\n",
1201 {0xffff0300, 0x02000001, 0x800f0000, 0x90e41000, 0x0000ffff}
1202 },
1203 { /* shader 3 */
1204 "ps_3_0\n"
1205 "mov r0, vFace\n",
1206 {0xffff0300, 0x02000001, 0x800f0000, 0x90e41001, 0x0000ffff}
1207 },
1208 { /* shader 4 */
1209 "ps_3_0\n"
1210 "mov r0, v[ aL + 12 ]\n",
1211 {0xffff0300, 0x03000001, 0x800f0000, 0x90e4200c, 0xf0e40800, 0x0000ffff}
1212 },
1213 { /* shader 5 */
1214 "ps_3_0\n"
1215 "loop aL, i0\n"
1216 "mov r0, v0[aL]\n"
1217 "endloop\n",
1218 {0xffff0300, 0x0200001b, 0xf0e40800, 0xf0e40000, 0x03000001, 0x800f0000,
1219 0x90e42000, 0xf0e40800, 0x0000001d, 0x0000ffff}
1220 },
1221 { /* shader 6 */
1222 "ps_3_0\n"
1223 "texldl r0, v0, s0\n",
1224 {0xffff0300, 0x0300005f, 0x800f0000, 0x90e40000, 0xa0e40800, 0x0000ffff}
1225 },
1226 { /* shader 7 */
1227 "ps_3_0\n"
1228 "add_pp r0, r0, r1\n",
1229 {0xffff0300, 0x03000002, 0x802f0000, 0x80e40000, 0x80e40001, 0x0000ffff}
1230 },
1231 { /* shader 8 */
1232 "ps_3_0\n"
1233 "dsx_sat r0, r1\n",
1234 {0xffff0300, 0x0200005b, 0x801f0000, 0x80e40001, 0x0000ffff}
1235 },
1236 { /* shader 9 */
1237 "ps_3_0\n"
1238 "texldd_pp r0, r1, r2, r3, r4\n",
1239 {0xffff0300, 0x0500005d, 0x802f0000, 0x80e40001, 0x80e40002, 0x80e40003,
1240 0x80e40004, 0x0000ffff}
1241 },
1242 { /* shader 10 */
1243 "ps_3_0\n"
1244 "texkill v0\n",
1245 {0xffff0300, 0x01000041, 0x900f0000, 0x0000ffff}
1246 },
1247 { /* shader 11 */
1248 "ps_3_0\n"
1249 "add oC3, r0, r1\n",
1250 {0xffff0300, 0x03000002, 0x800f0803, 0x80e40000, 0x80e40001, 0x0000ffff}
1251 },
1252 { /* shader 12 */
1253 "ps_3_0\n"
1254 "dcl_texcoord0_centroid v0\n",
1255 {0xffff0300, 0x0200001f, 0x80000005, 0x904f0000, 0x0000ffff}
1256 },
1257 { /* shader 13 */
1258 "ps_3_0\n"
1259 "dcl_2d_centroid s0\n",
1260 {0xffff0300, 0x0200001f, 0x90000000, 0xa04f0800, 0x0000ffff}
1261 },
1262 { /* shader 14 */
1263 "ps.3.0\n"
1264 "dcl_2d_pp s0\n",
1265 {0xffff0300, 0x0200001f, 0x90000000, 0xa02f0800, 0x0000ffff}
1266 },
1267 };
1268
1269 exec_tests("ps_3_0", tests, ARRAY_SIZE(tests));
1270}

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( asm  )

Definition at line 1758 of file asm.c.

1759{
1760 HMODULE d3dcompiler;
1761 char buffer[20];
1762
1763 sprintf(buffer, "d3dcompiler_%d", D3D_COMPILER_VERSION);
1764 d3dcompiler = GetModuleHandleA(buffer);
1765 pD3DAssemble = (void *)GetProcAddress(d3dcompiler, "D3DAssemble");
1766
1767 preproc_test();
1768 ps_1_1_test();
1769 vs_1_1_test();
1770 ps_1_3_test();
1771 ps_1_4_test();
1772 vs_2_0_test();
1773 vs_2_x_test();
1774 ps_2_0_test();
1775 ps_2_x_test();
1776 vs_3_0_test();
1777 ps_3_0_test();
1778
1779 failure_test();
1780
1782
1785}
#define D3D_COMPILER_VERSION
Definition: d3d11shader.h:26
static void vs_3_0_test(void)
Definition: asm.c:1096
static void ps_2_0_test(void)
Definition: asm.c:885
static void preproc_test(void)
Definition: asm.c:87
static void ps_1_4_test(void)
Definition: asm.c:523
static void ps_1_1_test(void)
Definition: asm.c:114
static void vs_1_1_test(void)
Definition: asm.c:140
static void ps_1_3_test(void)
Definition: asm.c:283
static void failure_test(void)
Definition: asm.c:1272
static void test_disassemble_shader(void)
Definition: asm.c:1741
static void ps_2_x_test(void)
Definition: asm.c:958
static void ps_3_0_test(void)
Definition: asm.c:1186
static void vs_2_x_test(void)
Definition: asm.c:824
static void vs_2_0_test(void)
Definition: asm.c:633
static void assembleshader_test(void)
Definition: asm.c:1524
static void d3dpreprocess_test(void)
Definition: asm.c:1607
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
GLuint buffer
Definition: glext.h:5915
#define sprintf
Definition: sprintf.c:45

◆ test_disassemble_shader()

static void test_disassemble_shader ( void  )
static

Definition at line 1741 of file asm.c.

1742{
1743 ID3DBlob *blob;
1744 HRESULT hr;
1745
1746 hr = D3DDisassemble(vs_2_0, 0, 0, NULL, &blob);
1747#if D3D_COMPILER_VERSION >= 46
1748 ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
1749#else
1750 ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
1751#endif
1752
1753 hr = D3DDisassemble(vs_2_0, sizeof(vs_2_0), 0, NULL, &blob);
1754 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
1755 ID3D10Blob_Release(blob);
1756}
static const DWORD vs_2_0[]
Definition: asm.c:1726
HRESULT WINAPI D3DDisassemble(const void *data, SIZE_T size, UINT flags, const char *comments, ID3DBlob **disassembly)
Definition: compiler.c:668
#define E_FAIL
Definition: ddrawi.h:102
Definition: image.c:229

Referenced by START_TEST().

◆ testD3DInclude_close()

static HRESULT WINAPI testD3DInclude_close ( ID3DInclude *  iface,
const void *  data 
)
static

Definition at line 1508 of file asm.c.

1509{
1510 free((void *)data);
1511 return S_OK;
1512}
#define free
Definition: debug_ros.c:5
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950

◆ testD3DInclude_open()

static HRESULT WINAPI testD3DInclude_open ( ID3DInclude *  iface,
D3D_INCLUDE_TYPE  include_type,
const char *  filename,
const void *  parent_data,
const void **  data,
UINT *  bytes 
)
static

Definition at line 1449 of file asm.c.

1451{
1452 static const char include[] = "#define REGISTER r0\nvs.1.1\n";
1453 static const char include2[] = "#include \"incl3.vsh\"\n";
1454 static const char include3[] = "vs.1.1\n";
1455 static const char include4[] = "#include <incl3.vsh>\n";
1456 char *buffer;
1457
1458 trace("include_type = %d, filename %s\n", include_type, filename);
1459 trace("parent_data (%p) -> %s\n", parent_data, parent_data ? (char *)parent_data : "(null)");
1460
1461 if (!strcmp(filename, "incl.vsh"))
1462 {
1464 *bytes = sizeof(include);
1465 ok(!parent_data, "Wrong parent_data value.\n");
1466 }
1467 else if (!strcmp(filename, "incl2.vsh"))
1468 {
1469 buffer = strdup(include2);
1470 *bytes = sizeof(include2);
1471 ok(!parent_data, "Wrong parent_data value.\n");
1472 ok(include_type == D3D_INCLUDE_LOCAL, "Wrong include type %d.\n", include_type);
1473 }
1474 else if (!strcmp(filename, "incl3.vsh"))
1475 {
1476 buffer = strdup(include3);
1477 *bytes = sizeof(include3);
1478 /* Also check for the correct parent_data content */
1479 ok(parent_data != NULL
1480 && (!strncmp(include2, parent_data, strlen(include2))
1481 || !strncmp(include4, parent_data, strlen(include4))),
1482 "Wrong parent_data value.\n");
1483 }
1484 else if (!strcmp(filename, "incl4.vsh"))
1485 {
1486 buffer = strdup(include4);
1487 *bytes = sizeof(include4);
1488 ok(parent_data == NULL, "Wrong parent_data value.\n");
1489 ok(include_type == D3D_INCLUDE_SYSTEM, "Wrong include type %d.\n", include_type);
1490 }
1491 else if (!strcmp(filename, "includes/incl.vsh"))
1492 {
1494 *bytes = sizeof(include);
1495 ok(!parent_data, "Wrong parent_data value.\n");
1496 }
1497 else
1498 {
1499 ok(FALSE, "Unexpected file %s included.\n", filename);
1500 return E_FAIL;
1501 }
1502
1503 *data = buffer;
1504
1505 return S_OK;
1506}
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
_ACRTIMP int __cdecl strncmp(const char *, const char *, size_t)
Definition: string.c:3335
static char * strdup(const char *buf)
Definition: string.h:83
const char * filename
Definition: ioapi.h:137

◆ vs_1_1_test()

static void vs_1_1_test ( void  )
static

Definition at line 140 of file asm.c.

140 {
141 struct shader_test tests[] = {
142 /* Basic instruction tests */
143 { /* shader 0 */
144 "vs_1_1\n"
145 "add r0, r1, r2\n",
146 {0xfffe0101, 0x00000002, 0x800f0000, 0x80e40001, 0x80e40002, 0x0000ffff}
147 },
148 { /* shader 1 */
149 "vs_1_1\n"
150 "nop\n",
151 {0xfffe0101, 0x00000000, 0x0000ffff}
152 },
153 /* Output register tests */
154 { /* shader 2 */
155 "vs_1_1\n"
156 "mov oPos, c0\n",
157 {0xfffe0101, 0x00000001, 0xc00f0000, 0xa0e40000, 0x0000ffff}
158 },
159 { /* shader 3 */
160 "vs_1_1\n"
161 "mov oT0, c0\n",
162 {0xfffe0101, 0x00000001, 0xe00f0000, 0xa0e40000, 0x0000ffff}
163 },
164 { /* shader 4 */
165 "vs_1_1\n"
166 "mov oT5, c0\n",
167 {0xfffe0101, 0x00000001, 0xe00f0005, 0xa0e40000, 0x0000ffff}
168 },
169 { /* shader 5 */
170 "vs_1_1\n"
171 "mov oD0, c0\n",
172 {0xfffe0101, 0x00000001, 0xd00f0000, 0xa0e40000, 0x0000ffff}
173 },
174 { /* shader 6 */
175 "vs_1_1\n"
176 "mov oD1, c0\n",
177 {0xfffe0101, 0x00000001, 0xd00f0001, 0xa0e40000, 0x0000ffff}
178 },
179 { /* shader 7 */
180 "vs_1_1\n"
181 "mov oFog, c0.x\n",
182 {0xfffe0101, 0x00000001, 0xc00f0001, 0xa0000000, 0x0000ffff}
183 },
184 { /* shader 8 */
185 "vs_1_1\n"
186 "mov oPts, c0.x\n",
187 {0xfffe0101, 0x00000001, 0xc00f0002, 0xa0000000, 0x0000ffff}
188 },
189 /* A bunch of tests for declarations */
190 { /* shader 9 */
191 "vs_1_1\n"
192 "dcl_position0 v0",
193 {0xfffe0101, 0x0000001f, 0x80000000, 0x900f0000, 0x0000ffff}
194 },
195 { /* shader 10 */
196 "vs_1_1\n"
197 "dcl_position v1",
198 {0xfffe0101, 0x0000001f, 0x80000000, 0x900f0001, 0x0000ffff}
199 },
200 { /* shader 11 */
201 "vs_1_1\n"
202 "dcl_normal12 v15",
203 {0xfffe0101, 0x0000001f, 0x800c0003, 0x900f000f, 0x0000ffff}
204 },
205 { /* shader 12 */
206 "vs_1_1\n"
207 "add r0, v0, v1\n",
208 {0xfffe0101, 0x00000002, 0x800f0000, 0x90e40000, 0x90e40001, 0x0000ffff}
209 },
210 { /* shader 13 */
211 "vs_1_1\n"
212 "def c12, 0, -1, -0.5, 1024\n",
213 {0xfffe0101, 0x00000051, 0xa00f000c, 0x00000000, 0xbf800000, 0xbf000000,
214 0x44800000, 0x0000ffff},
215 },
216 { /* shader 14: writemasks, swizzles */
217 "vs_1_1\n"
218 "dp4 r0.xw, r1.wzyx, r2.xxww\n",
219 {0xfffe0101, 0x00000009, 0x80090000, 0x801b0001, 0x80f00002, 0x0000ffff}
220 },
221 { /* shader 15: negation input modifier. Other modifiers not supprted in vs_1_1 */
222 "vs_1_1\n"
223 "add r0, -r0.x, -r1\n",
224 {0xfffe0101, 0x00000002, 0x800f0000, 0x81000000, 0x81e40001, 0x0000ffff}
225 },
226 { /* shader 16: relative addressing */
227 "vs_1_1\n"
228 "mov r0, c0[a0.x]\n",
229 {0xfffe0101, 0x00000001, 0x800f0000, 0xa0e42000, 0x0000ffff}
230 },
231 { /* shader 17: relative addressing */
232 "vs_1_1\n"
233 "mov r0, c1[a0.x + 2]\n",
234 {0xfffe0101, 0x00000001, 0x800f0000, 0xa0e42003, 0x0000ffff}
235 },
236 { /* shader 18 */
237 "vs_1_1\n"
238 "def c0, 1.0f, 1.0f, 1.0f, 0.5f\n",
239 {0xfffe0101, 0x00000051, 0xa00f0000, 0x3f800000, 0x3f800000, 0x3f800000,
240 0x3f000000, 0x0000ffff}
241 },
242 /* Other relative addressing tests */
243 { /* shader 19 */
244 "vs_1_1\n"
245 "mov r0, c[ a0.x + 12 ]\n",
246 {0xfffe0101, 0x00000001, 0x800f0000, 0xa0e4200c, 0x0000ffff}
247 },
248 { /* shader 20 */
249 "vs_1_1\n"
250 "mov r0, c[ 2 + a0.x ]\n",
251 {0xfffe0101, 0x00000001, 0x800f0000, 0xa0e42002, 0x0000ffff}
252 },
253 { /* shader 21 */
254 "vs_1_1\n"
255 "mov r0, c[ 2 + a0.x + 12 ]\n",
256 {0xfffe0101, 0x00000001, 0x800f0000, 0xa0e4200e, 0x0000ffff}
257 },
258 { /* shader 22 */
259 "vs_1_1\n"
260 "mov r0, c[ 2 + 10 + 12 ]\n",
261 {0xfffe0101, 0x00000001, 0x800f0000, 0xa0e40018, 0x0000ffff}
262 },
263 { /* shader 23 */
264 "vs_1_1\n"
265 "mov r0, c4[ 2 ]\n",
266 {0xfffe0101, 0x00000001, 0x800f0000, 0xa0e40006, 0x0000ffff}
267 },
268 { /* shader 24 */
269 "vs_1_1\n"
270 "rcp r0, v0.x\n",
271 {0xfffe0101, 0x00000006, 0x800f0000, 0x90000000, 0x0000ffff}
272 },
273 { /* shader 25 */
274 "vs.1.1\n"
275 "rsq r0, v0.x\n",
276 {0xfffe0101, 0x00000007, 0x800f0000, 0x90000000, 0x0000ffff}
277 },
278 };
279
280 exec_tests("vs_1_1", tests, ARRAY_SIZE(tests));
281}

Referenced by START_TEST().

◆ vs_2_0_test()

static void vs_2_0_test ( void  )
static

Definition at line 633 of file asm.c.

633 {
634 struct shader_test tests[] = {
635 /* Basic instruction tests */
636 { /* shader 0 */
637 "vs_2_0\n"
638 "mov r0, r1\n",
639 {0xfffe0200, 0x02000001, 0x800f0000, 0x80e40001, 0x0000ffff}
640 },
641 { /* shader 1 */
642 "vs_2_0\n"
643 "lrp r0, v0, c0, r1\n",
644 {0xfffe0200, 0x04000012, 0x800f0000, 0x90e40000, 0xa0e40000, 0x80e40001,
645 0x0000ffff}
646 },
647 { /* shader 2 */
648 "vs_2_0\n"
649 "dp4 oPos, v0, c0\n",
650 {0xfffe0200, 0x03000009, 0xc00f0000, 0x90e40000, 0xa0e40000, 0x0000ffff}
651 },
652 { /* shader 3 */
653 "vs_2_0\n"
654 "mov r0, c0[a0.x]\n",
655 {0xfffe0200, 0x03000001, 0x800f0000, 0xa0e42000, 0xb0000000, 0x0000ffff}
656 },
657 { /* shader 4 */
658 "vs_2_0\n"
659 "mov r0, c0[a0.y]\n",
660 {0xfffe0200, 0x03000001, 0x800f0000, 0xa0e42000, 0xb0550000, 0x0000ffff}
661 },
662 { /* shader 5 */
663 "vs_2_0\n"
664 "mov r0, c0[a0.z]\n",
665 {0xfffe0200, 0x03000001, 0x800f0000, 0xa0e42000, 0xb0aa0000, 0x0000ffff}
666 },
667 { /* shader 6 */
668 "vs_2_0\n"
669 "mov r0, c0[a0.w]\n",
670 {0xfffe0200, 0x03000001, 0x800f0000, 0xa0e42000, 0xb0ff0000, 0x0000ffff}
671 },
672 { /* shader 7 */
673 "vs_2_0\n"
674 "mov r0, c0[a0.w].x\n",
675 {0xfffe0200, 0x03000001, 0x800f0000, 0xa0002000, 0xb0ff0000, 0x0000ffff}
676 },
677 { /* shader 8 */
678 "vs_2_0\n"
679 "mov r0, -c0[a0.w+5].x\n",
680 {0xfffe0200, 0x03000001, 0x800f0000, 0xa1002005, 0xb0ff0000, 0x0000ffff}
681 },
682 { /* shader 9 */
683 "vs_2_0\n"
684 "mov r0, c0[a0]\n",
685 {0xfffe0200, 0x03000001, 0x800f0000, 0xa0e42000, 0xb0e40000, 0x0000ffff}
686 },
687 { /* shader 10 */
688 "vs_2_0\n"
689 "mov r0, c0[a0.xyww]\n",
690 {0xfffe0200, 0x03000001, 0x800f0000, 0xa0e42000, 0xb0f40000, 0x0000ffff}
691 },
692 { /* shader 11 */
693 "vs_2_0\n"
694 "add r0, c0[a0.x], c1[a0.y]\n", /* validation would fail on this line */
695 {0xfffe0200, 0x05000002, 0x800f0000, 0xa0e42000, 0xb0000000, 0xa0e42001,
696 0xb0550000, 0x0000ffff}
697 },
698 { /* shader 12 */
699 "vs_2_0\n"
700 "rep i0\n"
701 "endrep\n",
702 {0xfffe0200, 0x01000026, 0xf0e40000, 0x00000027, 0x0000ffff}
703 },
704 { /* shader 13 */
705 "vs_2_0\n"
706 "if b0\n"
707 "else\n"
708 "endif\n",
709 {0xfffe0200, 0x01000028, 0xe0e40800, 0x0000002a, 0x0000002b, 0x0000ffff}
710 },
711 { /* shader 14 */
712 "vs_2_0\n"
713 "loop aL, i0\n"
714 "endloop\n",
715 {0xfffe0200, 0x0200001b, 0xf0e40800, 0xf0e40000, 0x0000001d, 0x0000ffff}
716 },
717 { /* shader 15 */
718 "vs_2_0\n"
719 "nrm r0, c0\n",
720 {0xfffe0200, 0x02000024, 0x800f0000, 0xa0e40000, 0x0000ffff}
721 },
722 { /* shader 16 */
723 "vs_2_0\n"
724 "crs r0, r1, r2\n",
725 {0xfffe0200, 0x03000021, 0x800f0000, 0x80e40001, 0x80e40002, 0x0000ffff}
726 },
727 { /* shader 17 */
728 "vs_2_0\n"
729 "sgn r0, r1, r2, r3\n",
730 {0xfffe0200, 0x04000022, 0x800f0000, 0x80e40001, 0x80e40002, 0x80e40003,
731 0x0000ffff}
732 },
733 { /* shader 18 */
734 "vs_2_0\n"
735 "sincos r0, r1, r2, r3\n",
736 {0xfffe0200, 0x04000025, 0x800f0000, 0x80e40001, 0x80e40002, 0x80e40003,
737 0x0000ffff}
738 },
739 { /* shader 19 */
740 "vs_2_0\n"
741 "pow r0, r1, r2\n",
742 {0xfffe0200, 0x03000020, 0x800f0000, 0x80e40001, 0x80e40002, 0x0000ffff}
743 },
744 { /* shader 20 */
745 "vs_2_0\n"
746 "mova a0.y, c0.z\n",
747 {0xfffe0200, 0x0200002e, 0xb0020000, 0xa0aa0000, 0x0000ffff}
748 },
749 { /* shader 21 */
750 "vs_2_0\n"
751 "defb b0, true\n"
752 "defb b1, false\n",
753 {0xfffe0200, 0x0200002f, 0xe00f0800, 0x00000001, 0x0200002f, 0xe00f0801,
754 0x00000000, 0x0000ffff}
755 },
756 { /* shader 22 */
757 "vs_2_0\n"
758 "defi i0, - 1, 1, 10, 0\n"
759 "defi i1, 0, 40, 30, 10\n",
760 {0xfffe0200, 0x05000030, 0xf00f0000, 0xffffffff, 0x00000001, 0x0000000a,
761 0x00000000, 0x05000030, 0xf00f0001, 0x00000000, 0x00000028, 0x0000001e,
762 0x0000000a, 0x0000ffff},
763 },
764 { /* shader 23 */
765 "vs_2_0\n"
766 "loop aL, i0\n"
767 "mov r0, c0[aL]\n"
768 "endloop\n",
769 {0xfffe0200, 0x0200001b, 0xf0e40800, 0xf0e40000, 0x03000001, 0x800f0000,
770 0xa0e42000, 0xf0e40800, 0x0000001d, 0x0000ffff}
771 },
772 { /* shader 24 */
773 "vs_2_0\n"
774 "call l0\n"
775 "ret\n"
776 "label l0\n"
777 "ret\n",
778 {0xfffe0200, 0x01000019, 0xa0e41000, 0x0000001c, 0x0100001e, 0xa0e41000,
779 0x0000001c, 0x0000ffff}
780 },
781 { /* shader 25 */
782 "vs_2_0\n"
783 "callnz l0, b0\n"
784 "ret\n"
785 "label l0\n"
786 "ret\n",
787 {0xfffe0200, 0x0200001a, 0xa0e41000, 0xe0e40800, 0x0000001c, 0x0100001e,
788 0xa0e41000, 0x0000001c, 0x0000ffff}
789 },
790 { /* shader 26 */
791 "vs_2_0\n"
792 "callnz l0, !b0\n"
793 "ret\n"
794 "label l0\n"
795 "ret\n",
796 {0xfffe0200, 0x0200001a, 0xa0e41000, 0xede40800, 0x0000001c, 0x0100001e,
797 0xa0e41000, 0x0000001c, 0x0000ffff}
798 },
799 { /* shader 27 */
800 "vs_2_0\n"
801 "if !b0\n"
802 "else\n"
803 "endif\n",
804 {0xfffe0200, 0x01000028, 0xede40800, 0x0000002a, 0x0000002b, 0x0000ffff}
805 },
806 { /* shader 28 */
807 "vs_2_0\n"
808 "call l3\n"
809 "ret\n"
810 "label l3\n"
811 "ret\n",
812 {0xfffe0200, 0x01000019, 0xa0e41003, 0x0000001c, 0x0100001e, 0xa0e41003, 0x0000001c, 0x0000ffff}
813 },
814 { /* shader 29: labels up to 2047 are accepted even in vs_2_0 */
815 "vs.2.0\n"
816 "call l2047\n",
817 {0xfffe0200, 0x01000019, 0xa0e417ff, 0x0000ffff}
818 },
819 };
820
821 exec_tests("vs_2_0", tests, ARRAY_SIZE(tests));
822}

Referenced by START_TEST().

◆ vs_2_x_test()

static void vs_2_x_test ( void  )
static

Definition at line 824 of file asm.c.

824 {
825 struct shader_test tests[] = {
826 { /* shader 0 */
827 "vs_2_x\n"
828 "rep i0\n"
829 "break\n"
830 "endrep\n",
831 {0xfffe0201, 0x01000026, 0xf0e40000, 0x0000002c, 0x00000027, 0x0000ffff}
832 },
833 { /* shader 1 */
834 "vs_2_x\n"
835 "if_ge r0, r1\n"
836 "endif\n",
837 {0xfffe0201, 0x02030029, 0x80e40000, 0x80e40001, 0x0000002b, 0x0000ffff}
838 },
839 { /* shader 2 */
840 "vs_2_x\n"
841 "rep i0\n"
842 "break_ne r0, r1\n"
843 "endrep",
844 {0xfffe0201, 0x01000026, 0xf0e40000, 0x0205002d, 0x80e40000, 0x80e40001,
845 0x00000027, 0x0000ffff}
846 },
847
848 /* predicates */
849 { /* shader 3 */
850 "vs_2_x\n"
851 "setp_gt p0, r0, r1\n"
852 "(!p0) add r2, r2, r3\n",
853 {0xfffe0201, 0x0301005e, 0xb00f1000, 0x80e40000, 0x80e40001, 0x14000002,
854 0x800f0002, 0xbde41000, 0x80e40002, 0x80e40003, 0x0000ffff}
855 },
856 { /* shader 4 */
857 "vs_2_x\n"
858 "if p0.x\n"
859 "else\n"
860 "endif\n",
861 {0xfffe0201, 0x01000028, 0xb0001000, 0x0000002a, 0x0000002b, 0x0000ffff}
862 },
863 { /* shader 5 */
864 "vs_2_x\n"
865 "callnz l0, !p0.z\n"
866 "ret\n"
867 "label l0\n"
868 "ret\n",
869 {0xfffe0201, 0x0200001a, 0xa0e41000, 0xbdaa1000, 0x0000001c,
870 0x0100001e, 0xa0e41000, 0x0000001c, 0x0000ffff}
871 },
872 { /* shader 6 */
873 "vs.2.x\n"
874 "rep i0\n"
875 "breakp p0.w\n"
876 "endrep\n",
877 {0xfffe0201, 0x01000026, 0xf0e40000, 0x01000060, 0xb0ff1000,
878 0x00000027, 0x0000ffff}
879 },
880 };
881
882 exec_tests("vs_2_x", tests, ARRAY_SIZE(tests));
883}

Referenced by START_TEST().

◆ vs_3_0_test()

static void vs_3_0_test ( void  )
static

Definition at line 1096 of file asm.c.

1096 {
1097 struct shader_test tests[] = {
1098 { /* shader 0 */
1099 "vs_3_0\n"
1100 "mov r0, c0\n",
1101 {0xfffe0300, 0x02000001, 0x800f0000, 0xa0e40000, 0x0000ffff}
1102 },
1103 { /* shader 1 */
1104 "vs_3_0\n"
1105 "dcl_2d s0\n",
1106 {0xfffe0300, 0x0200001f, 0x90000000, 0xa00f0800, 0x0000ffff}
1107 },
1108 { /* shader 2 */
1109 "vs_3_0\n"
1110 "dcl_position o0\n",
1111 {0xfffe0300, 0x0200001f, 0x80000000, 0xe00f0000, 0x0000ffff}
1112 },
1113 { /* shader 3 */
1114 "vs_3_0\n"
1115 "dcl_texcoord12 o11\n",
1116 {0xfffe0300, 0x0200001f, 0x800c0005, 0xe00f000b, 0x0000ffff}
1117 },
1118 { /* shader 4 */
1119 "vs_3_0\n"
1120 "texldl r0, v0, s0\n",
1121 {0xfffe0300, 0x0300005f, 0x800f0000, 0x90e40000, 0xa0e40800, 0x0000ffff}
1122 },
1123 { /* shader 5 */
1124 "vs_3_0\n"
1125 "mov r0, c0[aL]\n",
1126 {0xfffe0300, 0x03000001, 0x800f0000, 0xa0e42000, 0xf0e40800, 0x0000ffff}
1127 },
1128 { /* shader 6 */
1129 "vs_3_0\n"
1130 "mov o[ a0.x + 12 ], r0\n",
1131 {0xfffe0300, 0x03000001, 0xe00f200c, 0xb0000000, 0x80e40000, 0x0000ffff}
1132 },
1133 { /* shader 7 */
1134 "vs_3_0\n"
1135 "add_sat r0, r0, r1\n",
1136 {0xfffe0300, 0x03000002, 0x801f0000, 0x80e40000, 0x80e40001, 0x0000ffff}
1137 },
1138 { /* shader 8 */
1139 "vs_3_0\n"
1140 "mov r2, r1_abs\n",
1141 {0xfffe0300, 0x02000001, 0x800f0002, 0x8be40001, 0x0000ffff}
1142 },
1143 { /* shader 9 */
1144 "vs_3_0\n"
1145 "mov r2, r1.xygb\n",
1146 {0xfffe0300, 0x02000001, 0x800f0002, 0x80940001, 0x0000ffff}
1147 },
1148 { /* shader 10 */
1149 "vs_3_0\n"
1150 "mov r2.xyb, r1\n",
1151 {0xfffe0300, 0x02000001, 0x80070002, 0x80e40001, 0x0000ffff}
1152 },
1153 { /* shader 11 */
1154 "vs_3_0\n"
1155 "mova_sat a0.x, r1\n",
1156 {0xfffe0300, 0x0200002e, 0xb0110000, 0x80e40001, 0x0000ffff}
1157 },
1158 { /* shader 12 */
1159 "vs_3_0\n"
1160 "sincos r0, r1\n",
1161 {0xfffe0300, 0x02000025, 0x800f0000, 0x80e40001, 0x0000ffff}
1162 },
1163 { /* shader 13 */
1164 "vs_3_0\n"
1165 "def c0, 1.0f, 1.0f, 1.0f, 0.5f\n",
1166 {0xfffe0300, 0x05000051, 0xa00f0000, 0x3f800000, 0x3f800000, 0x3f800000,
1167 0x3f000000, 0x0000ffff}
1168 },
1169 { /* shader 14: no register number checks with relative addressing */
1170 "vs.3.0\n"
1171 "add r0, v20[aL], r2\n",
1172 {0xfffe0300, 0x04000002, 0x800f0000, 0x90e42014, 0xf0e40800, 0x80e40002,
1173 0x0000ffff}
1174 },
1175 { /* shader 15 */
1176 "vs.3.0\n"
1177 "add r0, v0[aL + 1 + 3], r2\n",
1178 {0xfffe0300, 0x04000002, 0x800f0000, 0x90e42004, 0xf0e40800, 0x80e40002,
1179 0x0000ffff}
1180 },
1181 };
1182
1183 exec_tests("vs_3_0", tests, ARRAY_SIZE(tests));
1184}

Referenced by START_TEST().

Variable Documentation

◆ D3DInclude_Vtbl

const struct ID3DIncludeVtbl D3DInclude_Vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI testD3DInclude_close(ID3DInclude *iface, const void *data)
Definition: asm.c:1508
static HRESULT WINAPI testD3DInclude_open(ID3DInclude *iface, D3D_INCLUDE_TYPE include_type, const char *filename, const void *parent_data, const void **data, UINT *bytes)
Definition: asm.c:1449

Definition at line 1514 of file asm.c.

Referenced by assembleshader_test(), and d3dpreprocess_test().

◆ datasize

◆ defines

Definition at line 31 of file asm.c.

Referenced by assembleshader_test(), create_effect(), D3D10CompileEffectFromMemory(), D3D10CompileShader(), D3DAssemble(), D3DCompile(), D3DCompileFromFile(), D3DPreprocess(), d3dpreprocess_test(), D3DX10CompileFromMemory(), D3DX10CreateEffectFromFileA(), D3DX10CreateEffectFromFileW(), D3DX10CreateEffectFromMemory(), D3DX10CreateEffectFromResourceA(), D3DX10CreateEffectFromResourceW(), D3DX10CreateEffectPoolFromFileA(), D3DX10CreateEffectPoolFromFileW(), D3DX10CreateEffectPoolFromMemory(), D3DX10PreprocessShaderFromMemory(), D3DX11CompileFromFileA(), D3DX11CompileFromFileW(), D3DX11CompileFromMemory(), d3dx9_effect_compiler_init(), d3dx9_effect_init(), D3DXAssembleShader(), D3DXAssembleShaderFromFileA(), D3DXAssembleShaderFromFileW(), D3DXAssembleShaderFromResourceA(), D3DXAssembleShaderFromResourceW(), D3DXCompileShader(), D3DXCompileShaderFromFileA(), D3DXCompileShaderFromFileW(), D3DXCompileShaderFromResourceA(), D3DXCompileShaderFromResourceW(), D3DXCreateEffect(), D3DXCreateEffectCompiler(), D3DXCreateEffectCompilerFromFileA(), D3DXCreateEffectCompilerFromFileW(), D3DXCreateEffectCompilerFromResourceA(), D3DXCreateEffectCompilerFromResourceW(), D3DXCreateEffectEx(), D3DXCreateEffectFromFileA(), D3DXCreateEffectFromFileExA(), D3DXCreateEffectFromFileExW(), D3DXCreateEffectFromFileW(), D3DXCreateEffectFromResourceA(), D3DXCreateEffectFromResourceExA(), D3DXCreateEffectFromResourceExW(), D3DXCreateEffectFromResourceW(), D3DXPreprocessShader(), D3DXPreprocessShaderFromFileA(), D3DXPreprocessShaderFromFileW(), D3DXPreprocessShaderFromResourceA(), D3DXPreprocessShaderFromResourceW(), and preprocess_shader().

◆ error_messages

◆ filename

Definition at line 30 of file asm.c.

◆ flags

◆ include

Definition at line 31 of file asm.c.

Referenced by assembleshader_test(), create_effect(), D3D10CompileEffectFromMemory(), D3D10CompileShader(), D3DAssemble(), D3DCompile(), D3DCompile2(), D3DCompileFromFile(), d3dcompiler_include_from_file_open(), D3DPreprocess(), d3dpreprocess_test(), D3DX10CompileFromMemory(), D3DX10CreateEffectFromFileA(), D3DX10CreateEffectFromFileW(), D3DX10CreateEffectFromMemory(), D3DX10CreateEffectFromResourceA(), D3DX10CreateEffectFromResourceW(), D3DX10CreateEffectPoolFromFileA(), D3DX10CreateEffectPoolFromFileW(), D3DX10CreateEffectPoolFromMemory(), D3DX10PreprocessShaderFromMemory(), D3DX11CompileFromFileA(), D3DX11CompileFromFileW(), D3DX11CompileFromMemory(), d3dx9_effect_compiler_init(), d3dx9_effect_init(), D3DXAssembleShader(), D3DXAssembleShaderFromFileA(), D3DXAssembleShaderFromFileW(), D3DXAssembleShaderFromResourceA(), D3DXAssembleShaderFromResourceW(), D3DXCompileShader(), D3DXCompileShaderFromFileA(), D3DXCompileShaderFromFileW(), D3DXCompileShaderFromResourceA(), D3DXCompileShaderFromResourceW(), D3DXCreateEffect(), D3DXCreateEffectCompiler(), D3DXCreateEffectCompilerFromFileA(), D3DXCreateEffectCompilerFromFileW(), D3DXCreateEffectCompilerFromResourceA(), D3DXCreateEffectCompilerFromResourceW(), D3DXCreateEffectEx(), D3DXCreateEffectFromFileA(), D3DXCreateEffectFromFileExA(), D3DXCreateEffectFromFileExW(), D3DXCreateEffectFromFileW(), D3DXCreateEffectFromResourceA(), D3DXCreateEffectFromResourceExA(), D3DXCreateEffectFromResourceExW(), D3DXCreateEffectFromResourceW(), d3dxpreprocess_test(), D3DXPreprocessShader(), D3DXPreprocessShaderFromFileA(), D3DXPreprocessShaderFromFileW(), D3DXPreprocessShaderFromResourceA(), D3DXPreprocessShaderFromResourceW(), preprocess_shader(), test_create_effect_from_file(), testD3DInclude_open(), testD3DXInclude_open(), and xsltParseStylesheetInclude().

◆ shader

◆ vs_2_0

const DWORD vs_2_0[]
static
Initial value:
=
{
0xfffe0200,
0x0200001f, 0x80000000, 0x900f0000,
0x0200001f, 0x80000003, 0x900f0001,
0x0200001f, 0x8001000a, 0x900f0002,
0x0200001f, 0x80000005, 0x900f0003,
0x02000001, 0xc00f0000, 0x90e40000,
0x02000001, 0xd00f0001, 0x90e40002,
0x02000001, 0xe0070000, 0x90e40003,
0x02000001, 0xc00f0001, 0x90ff0002,
0x02000001, 0xc00f0002, 0x90ff0001,
0x0000ffff
}

Definition at line 1726 of file asm.c.

Referenced by test_disassemble_shader(), test_effect_clone(), test_effect_parameter_block(), and test_shader_semantics().