Commit 311a1e01 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Handle SM1 comments in the frontend.

parent 5626e165
...@@ -494,12 +494,6 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st ...@@ -494,12 +494,6 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
while (!fe->shader_is_end(fe_data, &ptr)) while (!fe->shader_is_end(fe_data, &ptr))
{ {
struct wined3d_shader_instruction ins; struct wined3d_shader_instruction ins;
const char *comment;
UINT comment_size;
/* Skip comments. */
fe->shader_read_comment(&ptr, &comment, &comment_size);
if (comment) continue;
/* Fetch opcode. */ /* Fetch opcode. */
fe->shader_read_instruction(fe_data, &ptr, &ins); fe->shader_read_instruction(fe_data, &ptr, &ins);
...@@ -1214,13 +1208,6 @@ void shader_generate_main(const struct wined3d_shader *shader, struct wined3d_sh ...@@ -1214,13 +1208,6 @@ void shader_generate_main(const struct wined3d_shader *shader, struct wined3d_sh
while (!fe->shader_is_end(fe_data, &ptr)) while (!fe->shader_is_end(fe_data, &ptr))
{ {
const char *comment;
UINT comment_size;
/* Skip comment tokens. */
fe->shader_read_comment(&ptr, &comment, &comment_size);
if (comment) continue;
/* Read opcode. */ /* Read opcode. */
fe->shader_read_instruction(fe_data, &ptr, &ins); fe->shader_read_instruction(fe_data, &ptr, &ins);
...@@ -1342,36 +1329,6 @@ static void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe ...@@ -1342,36 +1329,6 @@ static void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe
while (!fe->shader_is_end(fe_data, &ptr)) while (!fe->shader_is_end(fe_data, &ptr))
{ {
struct wined3d_shader_instruction ins; struct wined3d_shader_instruction ins;
const char *comment;
UINT comment_size;
/* comment */
fe->shader_read_comment(&ptr, &comment, &comment_size);
if (comment)
{
if (comment_size > 4 && *(const DWORD *)comment == WINEMAKEFOURCC('T', 'E', 'X', 'T'))
{
const char *end = comment + comment_size;
const char *ptr = comment + 4;
const char *line = ptr;
TRACE("// TEXT\n");
while (ptr != end)
{
if (*ptr == '\n')
{
UINT len = ptr - line;
if (len && *(ptr - 1) == '\r') --len;
TRACE("// %s\n", debugstr_an(line, len));
line = ++ptr;
}
else ++ptr;
}
if (line != ptr) TRACE("// %s\n", debugstr_an(line, ptr - line));
}
else TRACE("// %s\n", debugstr_an(comment, comment_size));
continue;
}
fe->shader_read_instruction(fe_data, &ptr, &ins); fe->shader_read_instruction(fe_data, &ptr, &ins);
if (ins.handler_idx == WINED3DSIH_TABLE_SIZE) if (ins.handler_idx == WINED3DSIH_TABLE_SIZE)
......
...@@ -642,6 +642,48 @@ static void shader_sm1_read_immconst(const DWORD **ptr, struct wined3d_shader_sr ...@@ -642,6 +642,48 @@ static void shader_sm1_read_immconst(const DWORD **ptr, struct wined3d_shader_sr
*ptr += count; *ptr += count;
} }
static void shader_sm1_read_comment(const DWORD **ptr)
{
DWORD token = **ptr;
const char *comment;
UINT size;
while ((token & WINED3DSI_OPCODE_MASK) == WINED3D_SM1_OP_COMMENT)
{
size = (token & WINED3DSI_COMMENTSIZE_MASK) >> WINED3DSI_COMMENTSIZE_SHIFT;
comment = (const char *)++(*ptr);
*ptr += size;
if (size > 1 && *(const DWORD *)comment == WINEMAKEFOURCC('T', 'E', 'X', 'T'))
{
const char *end = comment + size * sizeof(token);
const char *p = comment + sizeof(token);
const char *line = p;
TRACE("// TEXT\n");
while (p != end)
{
if (*p == '\n')
{
UINT len = p - line;
if (len && *(p - 1) == '\r') --len;
TRACE("// %s\n", debugstr_an(line, len));
line = ++p;
}
else ++p;
}
if (line != p)
TRACE("// %s\n", debugstr_an(line, p - line));
}
else if (size)
TRACE("// %s\n", debugstr_an(comment, size * sizeof(token)));
else
break;
token = **ptr;
}
}
static void shader_sm1_read_instruction(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins) static void shader_sm1_read_instruction(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins)
{ {
const struct wined3d_sm1_opcode_info *opcode_info; const struct wined3d_sm1_opcode_info *opcode_info;
...@@ -650,6 +692,8 @@ static void shader_sm1_read_instruction(void *data, const DWORD **ptr, struct wi ...@@ -650,6 +692,8 @@ static void shader_sm1_read_instruction(void *data, const DWORD **ptr, struct wi
unsigned int i; unsigned int i;
const DWORD *p; const DWORD *p;
shader_sm1_read_comment(ptr);
opcode_token = *(*ptr)++; opcode_token = *(*ptr)++;
if (!(opcode_info = shader_get_opcode(priv, opcode_token))) if (!(opcode_info = shader_get_opcode(priv, opcode_token)))
{ {
...@@ -708,23 +752,6 @@ static void shader_sm1_read_instruction(void *data, const DWORD **ptr, struct wi ...@@ -708,23 +752,6 @@ static void shader_sm1_read_instruction(void *data, const DWORD **ptr, struct wi
} }
} }
static void shader_sm1_read_comment(const DWORD **ptr, const char **comment, UINT *comment_size)
{
DWORD token = **ptr;
UINT size;
if ((token & WINED3DSI_OPCODE_MASK) != WINED3D_SM1_OP_COMMENT)
{
*comment = NULL;
return;
}
size = (token & WINED3DSI_COMMENTSIZE_MASK) >> WINED3DSI_COMMENTSIZE_SHIFT;
*comment = (const char *)++(*ptr);
*comment_size = size * sizeof(DWORD);
*ptr += size;
}
static BOOL shader_sm1_is_end(void *data, const DWORD **ptr) static BOOL shader_sm1_is_end(void *data, const DWORD **ptr)
{ {
if (**ptr == WINED3DSP_END) if (**ptr == WINED3DSP_END)
...@@ -742,6 +769,5 @@ const struct wined3d_shader_frontend sm1_shader_frontend = ...@@ -742,6 +769,5 @@ const struct wined3d_shader_frontend sm1_shader_frontend =
shader_sm1_free, shader_sm1_free,
shader_sm1_read_header, shader_sm1_read_header,
shader_sm1_read_instruction, shader_sm1_read_instruction,
shader_sm1_read_comment,
shader_sm1_is_end, shader_sm1_is_end,
}; };
...@@ -789,12 +789,6 @@ static void shader_sm4_read_instruction(void *data, const DWORD **ptr, struct wi ...@@ -789,12 +789,6 @@ static void shader_sm4_read_instruction(void *data, const DWORD **ptr, struct wi
} }
} }
static void shader_sm4_read_comment(const DWORD **ptr, const char **comment, UINT *comment_size)
{
FIXME("ptr %p, comment %p, comment_size %p stub!\n", ptr, comment, comment_size);
*comment = NULL;
}
static BOOL shader_sm4_is_end(void *data, const DWORD **ptr) static BOOL shader_sm4_is_end(void *data, const DWORD **ptr)
{ {
struct wined3d_sm4_data *priv = data; struct wined3d_sm4_data *priv = data;
...@@ -807,6 +801,5 @@ const struct wined3d_shader_frontend sm4_shader_frontend = ...@@ -807,6 +801,5 @@ const struct wined3d_shader_frontend sm4_shader_frontend =
shader_sm4_free, shader_sm4_free,
shader_sm4_read_header, shader_sm4_read_header,
shader_sm4_read_instruction, shader_sm4_read_instruction,
shader_sm4_read_comment,
shader_sm4_is_end, shader_sm4_is_end,
}; };
...@@ -702,7 +702,6 @@ struct wined3d_shader_frontend ...@@ -702,7 +702,6 @@ struct wined3d_shader_frontend
void (*shader_free)(void *data); void (*shader_free)(void *data);
void (*shader_read_header)(void *data, const DWORD **ptr, struct wined3d_shader_version *shader_version); void (*shader_read_header)(void *data, const DWORD **ptr, struct wined3d_shader_version *shader_version);
void (*shader_read_instruction)(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins); void (*shader_read_instruction)(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins);
void (*shader_read_comment)(const DWORD **ptr, const char **comment, UINT *comment_size);
BOOL (*shader_is_end)(void *data, const DWORD **ptr); BOOL (*shader_is_end)(void *data, const DWORD **ptr);
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment