<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="h5">
> +HRESULT WINAPI D3DXGetShaderInputSemantics(const DWORD *byte_code, D3DXSEMANTIC *semantics, UINT *count)<br>
> +{<br>
> +    const DWORD *ptr = byte_code;<br>
> +    UINT i = 0;<br>
> +<br>
> +    TRACE("byte_code = %p, semantics = %p, count = %p\n", byte_code, semantics, count);<br>
> +<br>
> +    if (!byte_code)<br>
> +        return D3DERR_INVALIDCALL;<br>
> +<br>
> +    TRACE("Shader version: %#x\n", *ptr);<br>
> +<br>
> +    /* Look for the END token, skipping the VERSION token */<br>
> +    while (*++ptr != D3DSIO_END)<br>
<br>
</div></div>I think you should be a bit more careful in skipping non-opcode<br>
DWORDs, otherwise you could e.g. potentially match with constants from<br>
DEF instructions - very unlikely to happen in practice, sure, but<br>
since it can be easily avoided, why not?<br>
Take a look at shader_skip_opcode() from wined3d/shader_sm1.c. You can<br>
probably get away without having to write a table with the parameters<br>
count for each SM1 opcode by just skipping DWORDs with the most<br>
significant bit set (see shader_skip_unrecognized() from the same<br>
file). Of course you still have to special case DEF but that should be<br>
it.<br></blockquote><div><br></div><div>I was thinking about this kind of problem but followed what D3DXGetShaderSize does.<br></div><div>So D3DXGetShaderSize will have to be fixed as well.<br></div><div>So if I summarize:<br>
</div><div><br>if (sm > 2) handle instruction length<br></div><div>else if (comment or def instruction) special handling for them<br></div><div>else skip DWORD with bit 31 set<br><br>Is this correct?<br><br></div><div>
<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div class="h5"><br>
> +    {<br>
> +        /* Skip comments */<br>
> +        if ((*ptr & D3DSI_OPCODE_MASK) == D3DSIO_COMMENT)<br>
> +        {<br>
> +            ptr += ((*ptr & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT);<br>
> +        }<br>
> +        else if ((*ptr & D3DSI_OPCODE_MASK) == D3DSIO_DCL)<br>
> +        {<br>
> +            DWORD param1 = *++ptr;<br>
> +            DWORD param2 = *++ptr;<br>
> +            DWORD usage = param1 & 0x1f;<br>
> +            DWORD usage_index = (param1 >> 16) & 0xf;<br>
> +            DWORD reg_type = (((param2 >> 11) & 0x3) << 3) | ((param2 >> 28) & 0x7);<br>
> +<br>
> +            TRACE("D3DSIO_DCL param1: %#x, param2: %#x, usage: %u, usage_index: %u, reg_type: %u\n",<br>
> +                   param1, param2, usage, usage_index, reg_type);<br>
> +<br>
> +            if (reg_type == D3DSPR_INPUT)<br>
> +            {<br>
> +                if (semantics)<br>
> +                {<br>
> +                    semantics[i].Usage = usage;<br>
> +                    semantics[i].UsageIndex = usage_index;<br>
> +                }<br>
> +                i++;<br>
> +            }<br>
> +        }<br>
> +    }<br>
> +<br>
> +    if (count)<br>
> +        *count = i;<br>
> +<br>
> +    return D3D_OK;<br>
> +}<br>
<br>
</div></div>Have you tried to implement D3DXGetShaderOutputSemantics too? I<br>
suspect most of the code will be pretty much the same, in that case<br>
you could move the common code to a helper function and use it from<br>
both.<br>
You don't necessarily need to do this right now, just mentioning a<br>
potential follow-up.<br>
<div class=""><div class="h5"><br></div></div></blockquote></div>I tought about it too. There are indeed similar. I planned to do it later but I will do it in this patch since I have to update it anyway.<br><br></div><div class="gmail_extra">
Thanks<br></div><div class="gmail_extra">Christian<br></div></div>