sharpdx / SharpDX

SharpDX GitHub Repository
http://sharpdx.org
MIT License
1.7k stars 638 forks source link

[Direct3D12] ShaderResourceViewDescription #633

Closed RobyDX closed 9 years ago

RobyDX commented 9 years ago

Seems that ShaderResourceViewDescription is not mapping well. The value passed to MipLevels is red as MostDetailedMip. I'm using nuget 3.0.0 alpha02

ShaderResourceViewDescription desc = new ShaderResourceViewDescription
            {
                Dimension = ShaderResourceViewDimension.Texture2D,
                Format = resource.Description.Format,
                Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING            
          };
            desc.Texture2D.MipLevels = 1;
            desc.Texture2D.MostDetailedMip = 0;
            desc.Texture2D.ResourceMinLODClamp =0;

            Device.CreateShaderResourceView(resource, desc, heapPosition);

this is the error I recevied from debugger

D3D12 ERROR: ID3D12Device::CreateShaderResourceView: The Dimensions of the View are invalid due to at least one of the following conditions. MostDetailedMip (value = 1) must be between 0 and MipLevels-1 of the Texture Resource, 0, inclusively. With the current MostDetailedMip, MipLevels (value = 0) must be between 1 and 0, inclusively, or -1 to default to all mips from MostDetailedMip, in order that the View fit on the Texture. [ STATE_CREATION ERROR #31: CREATESHADERRESOURCEVIEW_INVALIDDIMENSIONS]

Also, miss D3D12_ENCODE_SHADER_4_COMPONENT_MAPPING and D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING Macro.

xoofx commented 9 years ago

It may be fixed by commit bd051d5ba276fadc03c3e2ce0e65a05f464be1e3

Btw, If you are going through Direct3D12, what would really help SharpDX is to port the official DirectX12 samples to SharpDX. I can at least trying to keep up with mapping problems, but don't have time porting them, but this is from where we will get actual mapping problems!

I will try to get some help on Twitter as well if you are doing this, thanks!

RobyDX commented 9 years ago

I'll try to port them. Actually it compile, It gave me just this 2 error but dlls are here.

Severity Code Description Project File Line Error Metadata file 'G:\SharpDX\Bin\Desktop\SharpDX.Direct2D1.dll' could not be found SharpDX.DirectComposition G:\SharpDX\Source\SharpDX.DirectComposition\CSC Error Metadata file 'G:\SharpDX\Bin\Desktop\SharpDX.DXGI.dll' could not be found SharpDX.Direct2D1 G:\SharpDX\Source\SharpDX.Direct2D1\CSC

Now I'm trying to run my demo and I tell you. Thanks for support

xoofx commented 9 years ago

Which VS are you using?

RobyDX commented 9 years ago

2015 Community Edition

RobyDX commented 9 years ago

Test done, now CreateShaderResourceView works great. Also I love the changes you've done to RootParameters. Now is a piece of cake prepare the RootTableDescription. Really a great job.

RobyDX commented 9 years ago

I close the issue, Direct3D12 works great for my test. my twitter is https://twitter.com/NotJustCode2 (I don't twitter so much, I've just opened it).