سؤال

i've been using the D3DX11CompileFromFile function to compile and create ID3D11VertexShader * and ID3D11PixelShader * from the blob pointer after, like so:

ID3D10Blob * vertexShaderBuffer;
ID3D10Blob * errorMessage;

if(FAILED(D3DX11CompileFromFile(vsFilename.c_str(), NULL, NULL, "LightVertexShader", "vs_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, NULL, &vertexShaderBuffer, &errorMessage, NULL)))
    return false;

if(FAILED(device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader)))
    return false;

where vsFilename is a valid std::string and m_vertexShader is an ID3D11ShaderVertex *. i'm curious what the fourth parameter is for? Where is it used, when would i use it, what does it do? does it matter what it is? I ask, because with where i call it in my code, i don't want the user to have to specify it if it has no other purpose than being unique.

هل كانت مفيدة؟

المحلول

It's a name of your vertex shader function in file

For example, if you have same code in shader file

...

PS_INPUT VS(VS_INPUT input)
{

    PS_INPUT output = (PS_INPUT) 0;
    ...

With function call like D3DX11CompileFromFile(shaderFileName.c_str(), nullptr, nullptr, "VS", ...); you explain to DirectX which function from shader file starts work with vertex shader

نصائح أخرى

Did you check the documentation on MSDN? The reference for the D3DX11CompileFromFile function says this about the pFunctionName parameter:

Name of the shader-entry point function where shader execution begins. When you compile an effect, D3DX11CompileFromFile ignores pFunctionName; we recommend that you set pFunctionName to NULL because it is good programming practice to set a pointer parameter to NULL if the called function will not use it.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top