Yuv422 Support in SDL2.0


#1

Hi,

I have been trying to implement a Yuv422 to RGB pixel shader conversion in “SDL_render_d3d.c”. I am unable to get the same format of compiled code used in this, an array “const DWORD shader_data[]” is used and this works fine but is a 420 converter, the source code and assembler are listed along with the command line needed to compile the source to assembler.

When I use fxc to compile a shader (.hlsl) i get a header file with byte code in it starting with ‘DXBC’ which as I understand it from lots of googling is the prefix for hlsl byte code. I have also tried doing a compile from file at run time which also creates a buffer containing the same.

when I try and create a PixelShader from this it fails with code 0x8876086c,

Does anyone know how to create the DWORD formatted ready to use format? this would seem to be the simplest way to move ahead

Working format

    const DWORD shader_data[] = {
        0xffff0200, 0x05000051, 0xa00f0000, 0xbd808081, 0xbf008081, 0xbf008081,
        ....... };

fxc generated format that does not work

const BYTE g_YuvToRgb[] =
{
68, 88, 66, 67, 25, 203,
28, 33, 88, 181, 245, 169,
… };


#2

When I use fxc to compile a shader (.hlsl) i get a header file with byte code in it starting with ‘DXBC’ which as I understand it from lots of googling is the prefix for hlsl byte code.

That’s bytecode for Shader Model 4 and later, which is a totally different format than previous versions.

Since we are using Direct3D9 in the render code, it will fail if you give it bytecode for anything higher than Shader Model 3.

Try compiling with /T ps_2_0 (or ps_3_0 if you can’t get away with 2_0) and see if that works better.


#3

Hi,

that makes sense and agrees with my further digging, just need to see if I can get the needed functionality from ps_2_0 but have managed to get it loading and running simpler shaders, this code works and creates a working shader from a file which makes testing quicker

D3DXCompileShaderFromFileA(“Yuv422ToRGB.hlsl”,
NULL, NULL,
“main”, “ps_2_0”,
0, &PixelShaderYuv422ToRgb, &ShaderErrors, &PixelConstants );