# HG changeset patch # User Ryan C. Gordon # Date 1208671433 14400 # Node ID ebd0921fdd3935e98a1c93e13aab6a6ae102c085 # Parent 4410cc03dade552f76cae585b78b9a7f3b9d059a Fixed DCL parse and D3D profile for ps_3_0. Apparently the spec is wrong about the bits in a ps_3_0 DCL for input registers. Also, we'll need to deal with "binding" these properly in GLSL later. diff -r 4410cc03dade -r ebd0921fdd39 mojoshader.c --- a/mojoshader.c Sat Apr 19 19:00:01 2008 -0400 +++ b/mojoshader.c Sun Apr 20 02:03:53 2008 -0400 @@ -1412,29 +1412,26 @@ const char *usage_str = ""; char index_str[16] = { '\0' }; - if (shader_is_vertex(ctx)) + if (arg->regtype == REG_TYPE_SAMPLER) + { + const TextureType ttype = (const TextureType) ctx->dwords[0]; + switch (ttype) + { + case TEXTURE_TYPE_2D: usage_str = "_2d"; break; + case TEXTURE_TYPE_CUBE: usage_str = "_cube"; break; + case TEXTURE_TYPE_VOLUME: usage_str = "_volume"; break; + default: fail(ctx, "unknown sampler texture type"); return; + } // switch + } // if + + else { const uint32 usage = ctx->dwords[0]; const uint32 index = ctx->dwords[1]; usage_str = usagestrs[usage]; if (index != 0) snprintf(index_str, sizeof (index_str), "%u", (uint) index); - } // if - - else if (shader_is_pixel(ctx)) - { - if (arg->regtype == REG_TYPE_SAMPLER) - { - const TextureType ttype = (const TextureType) ctx->dwords[0]; - switch (ttype) - { - case TEXTURE_TYPE_2D: usage_str = "_2d"; break; - case TEXTURE_TYPE_CUBE: usage_str = "_cube"; break; - case TEXTURE_TYPE_VOLUME: usage_str = "_volume"; break; - default: fail(ctx, "unknown sampler texture type"); return; - } // switch - } // if - } // else if + } // else output_line(ctx, "dcl%s%s%s", usage_str, index_str, dst0); } // emit_D3D_DCL @@ -3174,6 +3171,7 @@ } // parse_args_DEFB +// !!! FIXME: this function is kind of a mess. static int parse_args_DCL(Context *ctx) { int unsupported = 0; @@ -3197,7 +3195,13 @@ if ( (shader_is_pixel(ctx)) && (shader_version_atleast(ctx, 3, 0)) ) { if (regtype == REG_TYPE_INPUT) - reserved_mask = 0x7FFFFFFF; + { + const uint32 usage = (token & 0xF); + const uint32 index = ((token >> 16) & 0xF); + reserved_mask = 0x7FF0FFE0; + ctx->dwords[0] = usage; + ctx->dwords[1] = index; + } // if else if (regtype == REG_TYPE_MISCTYPE) {