Module: wine Branch: master Commit: 311a1e014843eb2357ac71d83e6cf871574363b4 URL: http://source.winehq.org/git/wine.git/?a=commit;h=311a1e014843eb2357ac71d83e...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Sun Oct 14 18:40:37 2012 +0200
wined3d: Handle SM1 comments in the frontend.
---
dlls/wined3d/shader.c | 43 --------------------------- dlls/wined3d/shader_sm1.c | 62 ++++++++++++++++++++++++++++----------- dlls/wined3d/shader_sm4.c | 7 ---- dlls/wined3d/wined3d_private.h | 1 - 4 files changed, 44 insertions(+), 69 deletions(-)
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 12d5f98..9c70f08 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -494,12 +494,6 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st while (!fe->shader_is_end(fe_data, &ptr)) { 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. */ fe->shader_read_instruction(fe_data, &ptr, &ins); @@ -1214,13 +1208,6 @@ void shader_generate_main(const struct wined3d_shader *shader, struct wined3d_sh
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. */ 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 while (!fe->shader_is_end(fe_data, &ptr)) { 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); if (ins.handler_idx == WINED3DSIH_TABLE_SIZE) diff --git a/dlls/wined3d/shader_sm1.c b/dlls/wined3d/shader_sm1.c index ae7e3a9..18885f5 100644 --- a/dlls/wined3d/shader_sm1.c +++ b/dlls/wined3d/shader_sm1.c @@ -642,6 +642,48 @@ static void shader_sm1_read_immconst(const DWORD **ptr, struct wined3d_shader_sr *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) { 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 unsigned int i; const DWORD *p;
+ shader_sm1_read_comment(ptr); + opcode_token = *(*ptr)++; 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 } }
-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) { if (**ptr == WINED3DSP_END) @@ -742,6 +769,5 @@ const struct wined3d_shader_frontend sm1_shader_frontend = shader_sm1_free, shader_sm1_read_header, shader_sm1_read_instruction, - shader_sm1_read_comment, shader_sm1_is_end, }; diff --git a/dlls/wined3d/shader_sm4.c b/dlls/wined3d/shader_sm4.c index f7a73fe..b69ba82 100644 --- a/dlls/wined3d/shader_sm4.c +++ b/dlls/wined3d/shader_sm4.c @@ -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) { struct wined3d_sm4_data *priv = data; @@ -807,6 +801,5 @@ const struct wined3d_shader_frontend sm4_shader_frontend = shader_sm4_free, shader_sm4_read_header, shader_sm4_read_instruction, - shader_sm4_read_comment, shader_sm4_is_end, }; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 41dd737..56bdbad 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -702,7 +702,6 @@ struct wined3d_shader_frontend void (*shader_free)(void *data); 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_comment)(const DWORD **ptr, const char **comment, UINT *comment_size); BOOL (*shader_is_end)(void *data, const DWORD **ptr); };