locked
DEVICE_DRAW_SAMPLER_NOT_SET

    Question

  •      Hi Everybody!!!

         I'm working on a game compiled as a Windows App running on Windows 8 using DirectX 11. I'm using Visual Studio 2012, specifically using Visual C++. I'm getting the following warning:

    "The Pixel Shader unit expects a Sampler to be set at Slot 0, but none is bound. This is perfectly valid, as a NULL Sampler maps to default Sampler state. However, the developer may not want to rely on the defaults.  [ EXECUTION WARNING #352: DEVICE_DRAW_SAMPLER_NOT_SET]"

          Now, here is the kicker: Every thing works. All my sprites, my 3D models, my custom shaders, my animations, and even my custom font are displayed correctly.

          The reason why I would like to fix such warning is because the game doesn't look as nice as it looks when using XNA:

     * When using XNA, the graphics "blend" with the background in a nice way, like in a "gradient" form, whereas

     * When using DirectX 11, the very same graphics don't blend as pretty: They look more like a "nearest pixel" kind of blend.

          Now, I'm suspecting that, even though the shader does specify a sampler (as MIN_MAG_MIP_LINEAR), chances are this is pretty much ignored and the default sampler is used instead (as MIN_MAG_MIP_POINT).

          Any help is greatly appreciated!!!!

          Tarh Ik


    Tarh ik

    Thursday, September 25, 2014 3:38 AM

Answers

  • Hi Tarh,

    Have you tried to set a sampler? if yes, have you called PSSetSamplers function to attach the sampler to the pixel shader?

    If you've done all above, I think we need to check your code to move forward. Could you please share a sample project which can reproduce the issue on OneDrive? That will be very helpful for us to find a suitable solution for your case.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    Alan Yao
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by Tarh ik Tuesday, October 28, 2014 6:32 PM
    Tuesday, September 30, 2014 1:56 AM
  • If you are porting from XNA to C++, you may want to look at DirectX Tool Kit (if you haven't already). The CommonStates helper creates the same kind of blend state objects as used by XNA 4.

    • Marked as answer by Tarh ik Tuesday, October 28, 2014 6:32 PM
    Tuesday, October 21, 2014 4:02 AM
  •      Hi Alan!!!

        Thank you very much for your insight. I found the problem: I was already calling the function PSSetSamplers, but I was calling it wrongly. Pretty much I was doing the following:

        d3dContext->PSSetSamplers(0, 1, &spsLinearWrap);

     * Using this line of code, everytime my game called that function, spsLinearWrap came back as null, so all information about the default sampler was gone. To solve the issue, I changed it as follows:

        d3dContext->PSSetSamplers(0, 1, spsLinearWrap.GetAddress());

     * Once I did that, my default sampler was no longer cleared after calling the function, and more important, the warning message in the immediate window no longer appears. I still have the very same image quality issues, but I'm sure that is due to some factors.

         The source of my confusion was that the DirectXTK has a "readme.txt" file that instructs to call the PSSetSamplers as follows:

        deviceContext->PSSetSamplers(0, 1, &samplerState);

     * Most likely, the idea was to create an array and in that array fill my samplers, whereas in my code I'm creating only one sampler, as everything is pretty much specified in my HLSL.

         Thanks again for your help!!!!!

         Tarh Ik


    Tarh ik

    • Marked as answer by Tarh ik Tuesday, October 28, 2014 6:33 PM
    Tuesday, October 28, 2014 6:01 PM

All replies

  • Hi Tarh,

    I am trying to involve someone familiar with this issue to come into this thread. Thank you for your understanding.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, September 26, 2014 9:33 AM
    Moderator
  • Thanks Herro!! I appreciate the effort :)

    Tarh ik

    Monday, September 29, 2014 1:03 PM
  • Hi Tarh,

    Have you tried to set a sampler? if yes, have you called PSSetSamplers function to attach the sampler to the pixel shader?

    If you've done all above, I think we need to check your code to move forward. Could you please share a sample project which can reproduce the issue on OneDrive? That will be very helpful for us to find a suitable solution for your case.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    Alan Yao
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by Tarh ik Tuesday, October 28, 2014 6:32 PM
    Tuesday, September 30, 2014 1:56 AM
  •      Hi Alan!!

         Thank you very much for your advice! I'm setting the sampler for the pixel shader in Register 0 using HLSL as follows:

    Texture2D txtSkin : register(t0);
    
    cbuffer clsPuppetShaderPxTxtMaterial01 : register(b0)
    {
        float4  vecMatColor;
        float4  vecMatColorHighLight;
        float4  vecMatColorLowLight;
        float   dblFaceOffset;
        float   dblLightCurtain;
        float   dblDummy1;
        float   dblDummy2;
    }
    
    SamplerState splSkin = sampler_state
    {
        Filter = MIN_MAG_MIP_POINT;
        AddressU = MIRROR;
        AddressV = MIRROR;
    };
    
    
    
    
    struct clsPuppetShaderPxPipeLine
    {
        float4 vecPosition : SV_POSITION;
        float3 vecNormal   : NORMAL;
        float2 vecTexCoord : TEXCOORD0;
    };
    
    float4 main(clsPuppetShaderPxPipeLine oMyInput) : SV_TARGET
    {
    ...

         Based on your comments, it seems that I need to set a "default sampler" from within DirectX but outside the shader, wether I do it from the shader or not. It sounds weird but it makes sense now that I understand more about DirectX. Let me try that and I'll let you know.

         Thanks!!!

          Tarh Ik.


    Tarh ik

    Tuesday, October 7, 2014 1:16 PM
  • Hi Tarh,

    Ping to see if you made any progress on this. Feel free to let me know if you need more assistent.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    Alan Yao
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, October 9, 2014 8:52 AM
  •      Hi Alan!!!

         I haven't been able to add the fix - It's on my to-do list. The problem is that I copied a massive amount of code from my old XNA games, and now nothing works. As soon as I sort this mess out, I'll let you know.

         Most likely, your answer is the right one. I just need to either finish what I've done, or pull up the latest backup :'(

         Thanks!!!

         Tarh ik


    Tarh ik

    Monday, October 20, 2014 10:38 PM
  • If you are porting from XNA to C++, you may want to look at DirectX Tool Kit (if you haven't already). The CommonStates helper creates the same kind of blend state objects as used by XNA 4.

    • Marked as answer by Tarh ik Tuesday, October 28, 2014 6:32 PM
    Tuesday, October 21, 2014 4:02 AM
  •      Hi Chuck,

         Thanks!!! That's what I did. I have to confess that I had to create some variations of some classes in order to fit my needs (support for x files, to be presice, as well as some features for custom bitmap fonts), however I do believe that the DirectXTK is the best way for any 3D game.

         Best Regards,

         Tarh Ik


    Tarh ik

    Wednesday, October 22, 2014 11:55 PM
  •      Hi Alan!!!

        Thank you very much for your insight. I found the problem: I was already calling the function PSSetSamplers, but I was calling it wrongly. Pretty much I was doing the following:

        d3dContext->PSSetSamplers(0, 1, &spsLinearWrap);

     * Using this line of code, everytime my game called that function, spsLinearWrap came back as null, so all information about the default sampler was gone. To solve the issue, I changed it as follows:

        d3dContext->PSSetSamplers(0, 1, spsLinearWrap.GetAddress());

     * Once I did that, my default sampler was no longer cleared after calling the function, and more important, the warning message in the immediate window no longer appears. I still have the very same image quality issues, but I'm sure that is due to some factors.

         The source of my confusion was that the DirectXTK has a "readme.txt" file that instructs to call the PSSetSamplers as follows:

        deviceContext->PSSetSamplers(0, 1, &samplerState);

     * Most likely, the idea was to create an array and in that array fill my samplers, whereas in my code I'm creating only one sampler, as everything is pretty much specified in my HLSL.

         Thanks again for your help!!!!!

         Tarh Ik


    Tarh ik

    • Marked as answer by Tarh ik Tuesday, October 28, 2014 6:33 PM
    Tuesday, October 28, 2014 6:01 PM