Skip to content

Commit

Permalink
Fixed DCL parse and D3D profile for ps_3_0.
Browse files Browse the repository at this point in the history
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.

--HG--
branch : trunk
  • Loading branch information
icculus committed Apr 20, 2008
1 parent 3f9d2b6 commit ba63b7b
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions mojoshader.c
Expand Up @@ -1412,29 +1412,26 @@ static void emit_D3D_DCL(Context *ctx)
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
Expand Down Expand Up @@ -3174,6 +3171,7 @@ static int parse_args_DEFB(Context *ctx)
} // parse_args_DEFB


// !!! FIXME: this function is kind of a mess.
static int parse_args_DCL(Context *ctx)
{
int unsupported = 0;
Expand All @@ -3197,7 +3195,13 @@ static int parse_args_DCL(Context *ctx)
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)
{
Expand Down

0 comments on commit ba63b7b

Please sign in to comment.