vkd3d-shader/sm1: Introduce a parser for the legacy D3D byte-code format.

This is largely derived from the parser in Wine/wined3d, as of wine-6.18.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet
2021-10-06 17:11:48 +02:00
committed by Alexandre Julliard
parent 28316b2694
commit f7662f9878
9 changed files with 1133 additions and 5 deletions

View File

@@ -132,22 +132,25 @@ static int get_escape_char(int c)
}
}
const char *debugstr_a(const char *str)
const char *debugstr_an(const char *str, size_t n)
{
char *buffer, *ptr;
int escape_char;
char c;
if (!str)
return "(null)";
if (n == SIZE_MAX)
n = strlen(str);
ptr = buffer = get_buffer();
*ptr++ = '"';
while ((c = *str++) && ptr <= buffer + VKD3D_DEBUG_BUFFER_SIZE - 8)
while (n-- && ptr <= buffer + VKD3D_DEBUG_BUFFER_SIZE - 8)
{
int escape_char = get_escape_char(c);
c = *str++;
if (escape_char)
if ((escape_char = get_escape_char(c)))
{
*ptr++ = '\\';
*ptr++ = escape_char;
@@ -167,7 +170,7 @@ const char *debugstr_a(const char *str)
}
*ptr++ = '"';
if (c)
if (++n)
{
*ptr++ = '.';
*ptr++ = '.';
@@ -178,6 +181,11 @@ const char *debugstr_a(const char *str)
return buffer;
}
const char *debugstr_a(const char *str)
{
return debugstr_an(str, SIZE_MAX);
}
static const char *debugstr_w16(const uint16_t *wstr)
{
char *buffer, *ptr;