Jump to content
  • Advertisement
MarcusAseth

DX11 Failing to create shader - help

Recommended Posts

Posted (edited)

Hi guys, I'm trying to learn this stuff but running into some problems 😕

I've compiled my .hlsl into a header file which contains the global variable with the precompiled shader data:

//...

// Approximately 83 instruction slots used
#endif

const BYTE g_vs[] =
{
     68,  88,  66,  67, 143,  82, 
     13, 236, 152, 133, 219, 113, 
    173, 135,  18,  87, 122, 208, 
    124,  76,   1,   0,   0,   0, 
     16,  76,   0,   0,   6,   0, 

//....

And now following the "Compiling at build time to header files" example at this msdn link , I've included the header files in my main.cpp and I'm trying to create the vertex shader like this:

	hr = g_d3dDevice->CreateVertexShader(g_vs, sizeof(g_vs), nullptr, &g_d3dVertexShader);
	if (FAILED(hr))
	{
		return -1;
	}

and this is failing, entering the if and returing -1.

Can someone point out what I'm doing wrong? 😕 

Edited by MarcusAseth

Share this post


Link to post
Share on other sites
Advertisement
Posted (edited)

Forget about that, I'm trying this way now, and still doesn't work:

	//Load Shaders

	ID3DBlob* vsBlob = nullptr;
	D3DReadFileToBlob(L"../Shaders/SimpleVertexShader.cso", &vsBlob);

	assert(vsBlob);
	assert(g_d3dDevice);

	hr = g_d3dDevice->CreateVertexShader(vsBlob->GetBufferPointer(), vsBlob->GetBufferSize(), nullptr, &g_d3dVertexShader);
	SafeRelease(vsBlob);
	if (FAILED(hr))
	{
		return -1;
	}

hr is failing with E_INVALIDARG...what am I doing wrong? ç_ç

Edited by MarcusAseth

Share this post


Link to post
Share on other sites
Posted (edited)

Seems it works if I compile using Shader Model 5.0 but not with Shader Model 5.1... why?! o_O

Feature level is D3D_FEATURE_LEVEL_11_0.

I have this vga here and it seems it supports shader model 5.1, so I'm confused 😕

 

Edited by MarcusAseth

Share this post


Link to post
Share on other sites
Posted (edited)

there is no option for 11.3 though, the only D3D11 flags are 

        D3D_FEATURE_LEVEL_11_0	= 0xb000,
        D3D_FEATURE_LEVEL_11_1	= 0xb100,

and if I use D3D_FEATURE_LEVEL_11_1, then my app will give error somewhere along the way...shouldn't my VGA be capable of handling D3D_FEATURE_LEVEL_11_1? Why did they make it so confusing? x_x

Edited by MarcusAseth

Share this post


Link to post
Share on other sites
Posted (edited)

To leverage the 11.3 feature level you actually have to create your 11.0 device as you actually do and then query the ID3D11Device3 interface on it.

The sample at this link make use of it : https://github.com/walbourn/directx-sdk-samples/blob/master/DXUT/Core/DXUT.cpp

 

#ifdef USE_DIRECT3D11_3
    // Direct3D 11.3
    {
        ID3D11Device3* pd3d11Device3 = nullptr;
        hr = pd3d11Device->QueryInterface( IID_PPV_ARGS(&pd3d11Device3) );
        if (SUCCEEDED(hr) && pd3d11Device3)
        {
            GetDXUTState().SetD3D11Device3(pd3d11Device3);

            ID3D11DeviceContext3* pd3dImmediateContext3 = nullptr;
            hr = pd3dImmediateContext->QueryInterface(IID_PPV_ARGS(&pd3dImmediateContext3));
            if (SUCCEEDED(hr) && pd3dImmediateContext3)
            {
                GetDXUTState().SetD3D11DeviceContext3(pd3dImmediateContext3);
            }
        }
    }
#endif

As you can see the pd3d11Device is the equivalent of your 11.0 device and the ID3D11Device3 interface is retrieved from it. ID3D11Device3 exposes all the new 11.3 methods that weren't there before.

 

Here's the microsoft reference to that interface : https://msdn.microsoft.com/en-us/library/windows/desktop/dn899218(v=vs.85).aspx

 

Also don't be too surprised if the website that you linked mention that it support DX12 and some other feature level while it doesn't. It's a relatively old card after all : https://forums.geforce.com/default/topic/1001222/nvidia-gtx-480-dx-12-/

Edited by ChuckNovice

Share this post


Link to post
Share on other sites

Shader model 5.1 isn't supported by DX11 at all, only DX12. There is no FL11.3, and successfully querying the ID3D11Device3 interface indicates that your OS has "DX11.3" but you don't actually need to query that interface to use those features - unless they're only available on that interface.

Share this post


Link to post
Share on other sites

Also still on the subject, regarding the first method I was trying to use in this post to load the shader (include the precompiled shader in header form), on MVS it frooze the IDE because I acidentally passed the mouse over the global variable I was trying to use and the IDE attempted to display the content of it (12.000 bytes) in a "popup window" in this form here :

cIUdRYY.png

Happened 3 times, that's why I had to switch method.

Did this happened to you guys too? How do you deal with it?

Share this post


Link to post
Share on other sites

Using Eclipse rather than visual studio, but I disabled automagic "enrichment" on hover. I will ask for a popup if I want one, thank you very much!

Sure you shouldn't post in Coding Horrors? :)

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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!