[vlc-devel] [PATCH] Direct3D shader support (HLSL)

xxcv xxcv07 at gmail.com
Tue Aug 17 00:35:02 CEST 2010


Hi,
On 17/08/2010 4:35 AM, Laurent Aimar wrote:
> Hi,
>
> On Sun, Aug 15, 2010 at 09:07:58PM -0700, Sasha Koruga wrote:
>> @@ -589,6 +633,40 @@ static int Direct3DOpen(vout_display_t *vd,
>> video_format_t *fmt)
>>           return VLC_EGENERIC;
>>       }
>>
>> +    if(sys->hd3d9x_dll) {
>> +        HRESULT (WINAPI * OurD3DXCreateEffectFromFileA)(
>> +            LPDIRECT3DDEVICE9               pDevice,
>> +            LPCSTR                          pSrcFile,
>> +            CONST D3DXMACRO*                pDefines,
>> +            LPD3DXINCLUDE                   pInclude,
>> +            DWORD                           Flags,
>> +            LPD3DXEFFECTPOOL                pPool,
>> +            LPD3DXEFFECT*                   ppEffect,
>> +            LPD3DXBUFFER*                   ppCompilationErrors);
>   Please, correctly align. No need for the terminal A.
>> +
>> +        OurD3DXCreateEffectFromFileA =
>> (void*)GetProcAddress(sys->hd3d9x_dll,
>> TEXT("D3DXCreateEffectFromFileA"));
>> +        if (!OurD3DXCreateEffectFromFileA) {
>> +            msg_Warn(vd, "Cannot locate reference to
>> D3DXCreateEffectFromFileA ABI in DLL; pixel shading will be
>> disabled");
>> +            sys->d3dxShader = NULL;
>> +        }
>> +        else {
>> +            LPD3DXBUFFER buffer = NULL;
>> +            DWORD dwShaderFlags = D3DXFX_NOT_CLONEABLE;
>> +            char fileLocation[512];
>> +            strncpy(fileLocation, config_GetUserDir( VLC_DATA_DIR ), 512);
>> +            strncat(fileLocation, "\\pixelShader.fx", 512 -
>> strlen(fileLocation));
> asprintf may also help here.
>
>> +            HRESULT hr = OurD3DXCreateEffectFromFileA(sys->d3ddev,
>> fileLocation, NULL, NULL, dwShaderFlags, NULL,
>> ((ID3DXEffect**)(&sys->d3dxShader)),&buffer);
>> +            if(FAILED(hr)) //try loading it from current directory as
>> oppose to VLC_DATA_DIR
>> +                hr = OurD3DXCreateEffectFromFileA(sys->d3ddev,
>> "pixelShader.fx", NULL, NULL, dwShaderFlags, NULL,
>> ((ID3DXEffect**)(&sys->d3dxShader)),&buffer);
>   I am not sure we want that one.
IMO,
Maybe you can place pixelShader.fx in plugins directory.
Then maybe you should create a sort of configure file for your 
pixelShader.fx file or a complete shaders list = 
convertbt,widen,detect,gamma18,gamma22,gammabt,invert,grayscale
And a corresponding settings under vlcrc if you want to save settings of 
which effects are actively enabled.
This will involve changing the core's config, or probably you can do 
this in the module itself.
Since this .fx is user configurable therefore it should be parsed at 
run-time don't you think so ? Otherwise then there's no point for a 
separate .fx file if everything is hard-coded.

>> +            if(FAILED(hr)) {
>> +               msg_Warn(vd, "D3DXCreateEffectFromFileA Error
>> (hr=0x%lX) -- pixel shading will be disabled (pixelShader.fx possibly
>> missing).", hr);
>> +               if(buffer)
>> +                   msg_Warn(vd, "HLSL Compilation Error: %s",
>> (char*)buffer->lpVtbl->GetBufferPointer(buffer));
>> +               sys->d3dxShader = NULL;
>> +            }
>> +        }
>> +    }
>> +

-- 
My VLC, My Way, My Style~



More information about the vlc-devel mailing list