mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/d3dbc: Adjust the token count for DEF and DEFI instructions in shader_sm1_skip_opcode().
This was broken by commit e390bc35e2c9b0a2110370f916033eea2366317e; that commit fixed the source count for these instructions, but didn't adjust shader_sm1_skip_opcode(). Note that this only affects shader model 1; later versions have a token count embedded in the initial opcode token.
This commit is contained in:
parent
e55b6a7fa1
commit
73c563ffb7
Notes:
Alexandre Julliard
2023-11-20 22:32:20 +01:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/479
@ -855,6 +855,14 @@ static void shader_sm1_skip_opcode(const struct vkd3d_shader_sm1_parser *sm1, co
|
|||||||
{
|
{
|
||||||
*ptr += 2;
|
*ptr += 2;
|
||||||
}
|
}
|
||||||
|
/* Somewhat similarly, DEF and DEFI have a single source, but need to read
|
||||||
|
* four tokens for that source. See shader_sm1_read_immconst().
|
||||||
|
* Technically shader model 1 doesn't have integer registers or DEFI; we
|
||||||
|
* handle it here anyway because it's easy. */
|
||||||
|
else if (opcode_info->vkd3d_opcode == VKD3DSIH_DEF || opcode_info->vkd3d_opcode == VKD3DSIH_DEFI)
|
||||||
|
{
|
||||||
|
*ptr += 3;
|
||||||
|
}
|
||||||
|
|
||||||
*ptr += (opcode_info->dst_count + opcode_info->src_count);
|
*ptr += (opcode_info->dst_count + opcode_info->src_count);
|
||||||
}
|
}
|
||||||
|
@ -238,6 +238,13 @@ static void test_d3dbc(void)
|
|||||||
0xfffe0100, /* vs_1_0 */
|
0xfffe0100, /* vs_1_0 */
|
||||||
0x0000ffff, /* end */
|
0x0000ffff, /* end */
|
||||||
};
|
};
|
||||||
|
static const uint32_t vs_dcl_def[] =
|
||||||
|
{
|
||||||
|
0xfffe0101, /* vs_1_1 */
|
||||||
|
0x0000001f, 0x80000000, 0x900f0000, /* dcl_position v0 */
|
||||||
|
0x00000051, 0xa00f0000, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, /* def c0, 1.0, 0.0, 0.0, 1.0 */
|
||||||
|
0x0000ffff, /* end */
|
||||||
|
};
|
||||||
static const uint32_t invalid_type[] =
|
static const uint32_t invalid_type[] =
|
||||||
{
|
{
|
||||||
0x00010100, /* <invalid>_1_0 */
|
0x00010100, /* <invalid>_1_0 */
|
||||||
@ -255,6 +262,10 @@ static void test_d3dbc(void)
|
|||||||
0x0000ffff, /* end */
|
0x0000ffff, /* end */
|
||||||
};
|
};
|
||||||
static const char expected[] = "vs_1_0\n";
|
static const char expected[] = "vs_1_0\n";
|
||||||
|
static const char expected_dcl_def[] =
|
||||||
|
"vs_1_1\n"
|
||||||
|
"dcl_position0 v0\n"
|
||||||
|
"def c0 = 1.00000000e+00, 0.00000000e+00, 0.00000000e+00, 1.00000000e+00\n";
|
||||||
|
|
||||||
info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO;
|
info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO;
|
||||||
info.next = NULL;
|
info.next = NULL;
|
||||||
@ -291,6 +302,15 @@ static void test_d3dbc(void)
|
|||||||
rc = vkd3d_shader_compile(&info, &d3d_asm, NULL);
|
rc = vkd3d_shader_compile(&info, &d3d_asm, NULL);
|
||||||
ok(rc == VKD3D_ERROR_INVALID_SHADER, "Got unexpected error code %d.\n", rc);
|
ok(rc == VKD3D_ERROR_INVALID_SHADER, "Got unexpected error code %d.\n", rc);
|
||||||
|
|
||||||
|
info.source.code = vs_dcl_def;
|
||||||
|
info.source.size = sizeof(vs_dcl_def);
|
||||||
|
rc = vkd3d_shader_compile(&info, &d3d_asm, NULL);
|
||||||
|
ok(rc == VKD3D_OK, "Got unexpected error code %d.\n", rc);
|
||||||
|
ok(d3d_asm.size == strlen(expected_dcl_def), "Got unexpected size %zu.\n", d3d_asm.size);
|
||||||
|
ok(!memcmp(d3d_asm.code, expected_dcl_def, d3d_asm.size), "Got unexpected code \"%.*s\"\n",
|
||||||
|
(int)d3d_asm.size, (char *)d3d_asm.code);
|
||||||
|
vkd3d_shader_free_shader_code(&d3d_asm);
|
||||||
|
|
||||||
info.source.code = invalid_type;
|
info.source.code = invalid_type;
|
||||||
info.source.size = sizeof(invalid_type);
|
info.source.size = sizeof(invalid_type);
|
||||||
rc = vkd3d_shader_compile(&info, &d3d_asm, NULL);
|
rc = vkd3d_shader_compile(&info, &d3d_asm, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user