Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 12 Oct 2006
Offline Last Active Apr 21 2015 12:59 PM

Posts I've Made

In Topic: [SharpDX] Unable to map a texture to staging buffer

19 April 2015 - 04:17 AM

Clearly I had some twisted understanding of what I was trying to do.


I finally got D3D debugging working (it's been refusing to work for me the last while) and it clearly said that my destination buffer was the wrong size given the source. Once the debugging information was coming out it was pretty explicit in what I was doing wrong smile.png.

D3D11 ERROR: ID3D11DeviceContext::ResolveSubresource: The SrcSubresource and DstSubresource dimensions are not equal. SrcSubresource = { width:64, height:64, depth:1 }. DstSubresource = { width:32768, height:1, depth:1 }. [ RESOURCE_MANIPULATION ERROR #290: DEVICE_RESOLVESUBRESOURCE_DESTINATION_INVALID]
D3D11 ERROR: ID3D11DeviceContext::ResolveSubresource: The formats of each Resource are not compatible each other. Source Resource format is (0xa, R16G16B16A16_FLOAT). Destination Resource format is (0, UNKNOWN). [ RESOURCE_MANIPULATION ERROR #292: DEVICE_RESOLVESUBRESOURCE_SOURCE_INVALID]
D3D11 ERROR: ID3D11DeviceContext::ResolveSubresource: Both Resources must be the same Resource type (ie. Texture2D). [ RESOURCE_MANIPULATION ERROR #290: DEVICE_RESOLVESUBRESOURCE_DESTINATION_INVALID]
D3D11 ERROR: ID3D11DeviceContext::ResolveSubresource: Destination Resource must be a D3D11_USAGE_DEFAULT, without multisampling, and without the BIND_DEPTH_STENCIL flag. The Destination Resource has 1 samples. [ RESOURCE_MANIPULATION ERROR #290: DEVICE_RESOLVESUBRESOURCE_DESTINATION_INVALID]

I had just a simple buffer stream. What I should have been using was another Texture2D only setup for staging. Here is what the fix looks like once I've moved over to using a Texture2D.

Texture2DDescription localBufferDesc = new Texture2DDescription();
localBufferDesc.Width = 64;
localBufferDesc.Height = 64;
localBufferDesc.MipLevels = numOfMips;
localBufferDesc.ArraySize = 1;
localBufferDesc.Format = SharpDX.DXGI.Format.R16G16B16A16_Float;
localBufferDesc.SampleDescription.Count = 1;
localBufferDesc.SampleDescription.Quality = 0;
localBufferDesc.Usage = ResourceUsage.Staging;
localBufferDesc.BindFlags = BindFlags.None;
localBufferDesc.CpuAccessFlags = CpuAccessFlags.Read;
localBufferDesc.OptionFlags = ResourceOptionFlags.None;
SharpDX.Direct3D11.Texture2D localbuffer = new SharpDX.Direct3D11.Texture2D(device, localBufferDesc);

device.Copy(emptyTexture, localbuffer);

DataStream data = new DataStream(8 * 64 * 64, true, true);
DataBox box = ((DeviceContext)device).MapSubresource(localbuffer, 0, 0, MapMode.Read, MapFlags.None, out data);

quickTest = data.ReadHalf4();

In Topic: SampleCmpLevelZero samples return 0 only

05 April 2015 - 01:44 PM

And just to show that RenderDoc was trying to warn me of my downfall, here's some shots with the unset and set sampler. They've even gone and highlighted it in red for me tongue.png


I had noticed this earlier in my debugging but I dismissed it too easily. I guess I didn't trust my tools. Lesson learned.


Attached File  SamplerFixed.png   303.1KB   3 downloads

Attached File  SamplerWarning.png   25.9KB   3 downloads

In Topic: SampleCmpLevelZero samples return 0 only

05 April 2015 - 01:24 PM

Amazing what some food can do. So after hours spent on this I finally have my answer.


Don't create your samplers in the .fx file. It's dependent on the Effects library and so it won't actually set the parameters that you ask for, just the default values.


So yeah, moving the sampler description into code and setting it there fit everything right up.


For some similar issues you can look here at least.




In Topic: ShaderResourceView sRGB format having no effect on sampler reads

16 March 2015 - 02:58 AM

Yeah, that'll teach me to look at answers at 2am. You're right that it makes sense to have both the format and filters in sRGB.


Thanks for the help!

In Topic: ShaderResourceView sRGB format having no effect on sampler reads

15 March 2015 - 07:06 PM

Thanks very much for the function explanation, it's definitely a little bit confusing biggrin.png.


I might need to look into some more details since applying just the filter didn't change things, but applying both the format and filter did.

imageLoadInfo.Format = SharpDX.DXGI.Format.R8G8B8A8_UNorm_SRgb;
imageLoadInfo.Filter = SharpDX.Direct3D11.FilterFlags.SRgb | SharpDX.Direct3D11.FilterFlags.None;

Thanks MJP!