Sign in to follow this  
Followers 0
Solid_Spy

DX11
Error using Effects in Directx 11.0

1 post in this topic

Hello, I've been trying to get an effect file to load in my directx game, however, i seem to get some strange errors. I followed the tutorial from a book I got, but it doesn't seem to work. It appears that I get the error every time i reach the CreateShaderFromMemory() function. Here's the code for my .cpp:

 

 

 

void InitPipeline()
{
    // load and compile the two shaders


    ID3D10Blob *compiledShader = 0;
    ID3D10Blob *errorMessage = 0;


    HRESULT hr;


    hr = D3DX11CompileFromFile("shader.txt", 0, 0, 0, "fx_5_0", D3D10_SHADER_DEBUG | D3D10_SHADER_SKIP_OPTIMIZATION, 0, 0, &compiledShader, &errorMessage, 0);


    if(FAILED(hr))
    {
        MessageBox(0, "shader compiler error", "ERROR", MB_OK);
    }


    errorMessage->Release();


    hr = D3DX11CreateEffectFromMemory(compiledShader->GetBufferPointer(), compiledShader->GetBufferSize(), 0, dev, &normalShader);
 

 

And here is my shader file:

 

 

 

struct vertexIn
{
    float3 position : POSITION;
    float4 color    : COLOR;
};


struct vertexOut
{
    float4 position : SV_POSITION;
    float4 color    : COLOR;
};


vertexOut VS(vertexIn vIn)
{
    vertexOut vOut;
    vOut.position = float4 (vIn.position, 1.0f);
    vOut.color = vIn.color;


    return vOut;
}


float4 PS(vertexOut pixelinsert) : SV_Target
{
    return pixelinsert.color;
}


technique11 t0
{
    pass p0
    {
        SetVertexShader(CompileShader(vs_5_0, VS()));
        SetPixelShader(CompileShader(ps_5_0, PS()));
    }
}
 

 

Here are the errors I am getting:

 

 

Error    3    error LNK1120: 2 unresolved externals    C:\..Project30.exe    1    1    Project30
Error    2    error LNK2019: unresolved external symbol _D3DGetInputSignatureBlob@12 referenced in function "protected: long __thiscall D3DX11Effects::CEffectLoader::BuildShaderBlock(struct D3DX11Effects::SShaderBlock *)" (?BuildShaderBlock@CEffectLoader@D3DX11Effects@@IAEJPAUSShaderBlock@2@@Z)    C:\...Effects11.lib(EffectLoad.obj)    Project30
Error    1    error LNK2019: unresolved external symbol _D3DReflect@16 referenced in function "protected: long __thiscall D3DX11Effects::CEffectLoader::BuildShaderBlock(struct D3DX11Effects::SShaderBlock *)" (?BuildShaderBlock@CEffectLoader@D3DX11Effects@@IAEJPAUSShaderBlock@2@@Z)    C:\...Effects11.lib(EffectLoad.obj)    Project30
 
Any help would be appreciated smile.png
Edited by Solid_Spy
0

Share this post


Link to post
Share on other sites

In your project properties under Linker > Input > Additional Dependencies is d3dcompiler.lib specified in this list? If not, try adding it. I had the same issue and it's because those methods are defined in d3dcompiler.lib and I was missing it in my Linker dependencies.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • By Jordy
      I'm copying mipmaps of a BC3 compressed texture region to a new (and bigger) BC3 compressed texture with ID3D11DeviceContext::CopySubresourceRegion.
      Unfortunately the new texture contains incorrect mipmaps when the width or height of a mipmap level are unaligned to the block size, which is 4 in the case of BC3.
      I think this has to do with the virtual and physical size of a mipmap level for block compressed textures: https://msdn.microsoft.com/en-us/library/windows/desktop/bb694531(v=vs.85).aspx#Virtual_Size
      There is also a warning:
      I don't know how to account for the physical memory size and if that's possible when using ID3D11DeviceContext::CopySubresourceRegion.
      Is it possible, and if so, how?
    • By thefoxbard
      From what the MSDN states, there are two ways of compiling HLSL shaders: either at runtime or "offline" -- using a tool like fxc.exe, for instance
      My question is, are there any risks in using pre-compiled shaders in the final game? I mean, is there any situation in which the pre-compiled shaders might not work?
      Or ideally shaders should always be compiled when lauching the game?
    • By maxest
      I have code like this:
      groupshared uint tempData[ElementsCount]; [numthreads(ElementsCount/2, 1, 1)] void CSMain(uint3 gID: SV_GroupID, uint3 gtID: SV_GroupThreadID) {     tempData[gtID.x] = 0; } And it works fine. Now I change it to this:
      void MyFunc(inout uint3 gtID: SV_GroupThreadID, inout uint inputData[ElementsCount]) {     inputData[gtID.x] = 0; } groupshared uint tempData[ElementsCount]; [numthreads(ElementsCount/2, 1, 1)] void CSMain(uint3 gID: SV_GroupID, uint3 gtID: SV_GroupThreadID) {     MyFunc(gtID, tempData); } and I get "error X3695: race condition writing to shared memory detected, consider making this write conditional.". Any way to go around this?
    • By maxest
      I implemented DX queries after this blog post:
      https://mynameismjp.wordpress.com/2011/10/13/profiling-in-dx11-with-queries/
      Queries work perfectly fine... for as long as I don't use VSync or any other form of Sleep. Why would that happe? I record queries right before my Compute/Dispatch code, record right after and then read the results (spinning on GetData if returns S_FALSE).
      When I don't VSync then my code takes consistent 0.39-0.4 ms. After turning VSync on it starts with something like 0.46 ms, after a second bumps up to 0.61 ms and a few seconds after I get something like 1.2 ms.
      I also used this source:
      http://reedbeta.com/blog/gpu-profiling-101/
      The difference here is that the author uses the disjoint query for the whole Render()  function instead of using one per particular measurement. When I implemented it this way the timings were incosistent (like above 0.46, 0.61, 1.2) regardless of VSync.
    • By amadeus12
      I wrote computeshader to blur image.
      But it returns black texture.
      actually I'm not using FX file and effect library.
      I use hlsl file and I bind it to pipeline myself with direct api.
      I have 2 hlsl files which do vertical, horizontal blur.
      here my CPU code which executes computeshader.
      void BoxApp::callComputeShaderandBlur(ID3D11DeviceContext * dc, ID3D11ShaderResourceView * inputSRV, ID3D11UnorderedAccessView * inputUAV, int blurcount)
      {
          for (int i = 0; i < blurcount; i++)
          {
              dc->CSSetShader(m_CSH, 0, 0);
              dc->CSSetShaderResources(0, 1, &inputSRV);
              dc->CSSetUnorderedAccessViews(0, 1, &mBlurOutPutTexUAV, 0);
            
              UINT numGroupsX = (UINT)ceilf(m_Width / 256.0f);
              dc->Dispatch(numGroupsX, m_Height, 1);
             
              dc->CSSetShaderResources(1, 0, 0);
              dc->CSSetUnorderedAccessViews(1, 0, 0, 0);
              dc->CSSetShader(m_CSV, 0, 0);
              dc->CSSetShaderResources(0, 1, &mBlurOutPutTexSRV);
              dc->CSSetUnorderedAccessViews(0, 1, &inputUAV, 0);
              UINT numGroupY = (UINT)ceilf(m_Height / 256.0f);
              dc->Dispatch(m_Width, numGroupY, 1);
              dc->CSSetShaderResources(1, 0, 0);
              dc->CSSetUnorderedAccessViews(1, 0, 0, 0);
          }
          dc->CSSetShaderResources(1, 0, 0);
          dc->CSSetUnorderedAccessViews(1, 0, 0, 0);
          dc->CSSetShader(0, 0, 0);
      }
      If I don't call this function, everything is fine. (I rendered my scene to off screen redertarget and use this texture as quad texture. and render it to real rendertarget. it worked fined)
      That means there's problem in ComputeShader code.
      Every resource and view isn't null pointer, I checked it.
      all HRESULTs are S_OK.
       
      here my 2 shader codes
       
      this is CSH.hlsl
      static float gWeights[11] =
      {
          0.05f, 0.05f, 0.1f, 0.1f, 0.1f, 0.2f, 0.1f, 0.1f, 0.1f, 0.05f, 0.05f,
      };
      static const int gBlurRadius = 5;
      Texture2D gInput;
      RWTexture2D<float4> gOutput;
      #define N 256
      #define CacheSize (N + 2*gBlurRadius)
      groupshared float4 gCache[CacheSize];
      [numthreads(N, 1, 1)]
      void main(int3 groupThreadID : SV_GroupThreadID,
          int3 dispatchThreadID : SV_DispatchThreadID)
      {
          //
          // Fill local thread storage to reduce bandwidth.  To blur 
          // N pixels, we will need to load N + 2*BlurRadius pixels
          // due to the blur radius.
          //
          // This thread group runs N threads.  To get the extra 2*BlurRadius pixels, 
          // have 2*BlurRadius threads sample an extra pixel.
          if (groupThreadID.x < gBlurRadius)
          {
              // Clamp out of bound samples that occur at image borders.
              int x = max(dispatchThreadID.x - gBlurRadius, 0);
              gCache[groupThreadID.x] = gInput[int2(x, dispatchThreadID.y)];
          }
          if (groupThreadID.x >= N - gBlurRadius)
          {
              // Clamp out of bound samples that occur at image borders.
              int x = min(dispatchThreadID.x + gBlurRadius, gInput.Length.x - 1);
              gCache[groupThreadID.x + 2 * gBlurRadius] = gInput[int2(x, dispatchThreadID.y)];
          }
          // Clamp out of bound samples that occur at image borders.
          gCache[groupThreadID.x + gBlurRadius] = gInput[min(dispatchThreadID.xy, gInput.Length.xy - 1)];
          // Wait for all threads to finish.
          GroupMemoryBarrierWithGroupSync();
          //
          // Now blur each pixel.
          //
          float4 blurColor = float4(0, 0, 0, 0);
          [unroll]
          for (int i = -gBlurRadius; i <= gBlurRadius; ++i)
          {
              int k = groupThreadID.x + gBlurRadius + i;
              blurColor += gWeights[i + gBlurRadius] * gCache[k];
          }
          gOutput[dispatchThreadID.xy] = blurColor;
      }
      and this is CSV
       
      static float gWeights[11] =
      {
              0.05f, 0.05f, 0.1f, 0.1f, 0.1f, 0.2f, 0.1f, 0.1f, 0.1f, 0.05f, 0.05f,
      };
      static const int gBlurRadius = 5;
      Texture2D gInput;
      RWTexture2D<float4> gOutput;
      #define N 256
      #define CacheSize (256 + 2*5)
      groupshared float4 gCache[CacheSize];

      [numthreads(1, N, 1)]
      void main(int3 groupThreadID : SV_GroupThreadID,
          int3 dispatchThreadID : SV_DispatchThreadID)
      {
          //
          // Fill local thread storage to reduce bandwidth.  To blur 
          // N pixels, we will need to load N + 2*BlurRadius pixels
          // due to the blur radius.
          //
          // This thread group runs N threads.  To get the extra 2*BlurRadius pixels, 
          // have 2*BlurRadius threads sample an extra pixel.
          if (groupThreadID.y < gBlurRadius)
          {
              // Clamp out of bound samples that occur at image borders.
              int y = max(dispatchThreadID.y - gBlurRadius, 0);
              gCache[groupThreadID.y] = gInput[int2(dispatchThreadID.x, y)];
          }
          if (groupThreadID.y >= N - gBlurRadius)
          {
              // Clamp out of bound samples that occur at image borders.
              int y = min(dispatchThreadID.y + gBlurRadius, gInput.Length.y - 1);
              gCache[groupThreadID.y + 2 * gBlurRadius] = gInput[int2(dispatchThreadID.x, y)];
          }
          // Clamp out of bound samples that occur at image borders.
          gCache[groupThreadID.y + gBlurRadius] = gInput[min(dispatchThreadID.xy, gInput.Length.xy - 1)];

          // Wait for all threads to finish.
          GroupMemoryBarrierWithGroupSync();
          //
          // Now blur each pixel.
          //
          float4 blurColor = float4(0, 0, 0, 0);
          [unroll]
          for (int i = -gBlurRadius; i <= gBlurRadius; ++i)
          {
              int k = groupThreadID.y + gBlurRadius + i;
              blurColor += gWeights[i + gBlurRadius] * gCache[k];
          }
          gOutput[dispatchThreadID.xy] = blurColor;
      }
       
       
      sorry about poor english.
      plz help I'm really sad...
      I spend whole day for this...
      It doesn't work..
      feels bad man..
  • Popular Now