[PATCH 2/6] d3dcompiler: Implement D3DGetBlobPart().
Henri Verbeet
hverbeet at gmail.com
Mon Sep 20 13:05:01 CDT 2010
2010/9/20 Rico Schüller <kgbricola at web.de>:
> Sure that abroach works pretty well for the D3DGetBlobPart() function, but
> you it is a bit ugly to use it for the D3DStripShader(). There you have to
> add some quirks. You would have to parse the dxbc twice to get the correct
> count (could be != count in dxbc original) and then parse only the needed
> blob parts. Therefore I added the dxbc_remove_section() function. I've
> attached all patches so that you could see what D3DStripShader() does.
>
Well, you'd do something like the following:
struct dxbc src_dxbc, dst_dxbc;
unsigned int i;
dxbc_init(&src_dxbc);
dxbc_init(&dst_dxbc);
dxbc_parse(&src_dxbc, data, data_size);
for (i = 0; i < src_dxbc.section_count; ++i)
{
struct dxbc_section *s = &src_dxbc.sections[i];
switch (s->tag)
{
case TAG_SDBG:
if (!(flags & D3DCOMPILER_STRIP_DEBUG_INFO))
dxbc_add_section(&dst_dxbc, s->tag, s->data, s->data_size);
break;
case TAG_RDEF:
case TAG_STAT:
if (!(flags & D3DCOMPILER_STRIP_REFLECTION_DATA))
dxbc_add_section(&dst_dxbc, s->tag, s->data, s->data_size);
break;
default:
dxbc_add_section(&dst_dxbc, s->tag, s->data, s->data_size);
break;
}
}
dxbc_write(&dst_dxbc, blob);
dxbc_destroy(&dst_dxbc);
dxbc_destroy(&src_dxbc);
But if it turns out to really be much nicer you could certainly
introduce a dxbc_remove_section() function, but I doubt it. In the
current patch it's simply dead code though. Somewhat related, do you
happen to know if section tags need to be unique within a DXBC? I'd
imagine the DXBC format doesn't restrict that, though specific
functions may have additional constraints on what is considered a
valid input DXBC.
More information about the wine-devel
mailing list