• Advertisement
Sign in to follow this  

MapSubresource error

This topic is 1849 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



I'm having a problem loading a Texture2DArray in SharpDX. This was working in SlimDX but there are some minor changes that I just don't understand or I'm just missing something I guess.


The error message I'm receiving is ...


HRESULT: [0x80070057], Module: [Unknown], ApiCode: [Unknown/Unknown], Message: The parameter is incorrect.


The method I'm calling to map my texture (for loading it into the texture array) is ...


DataBox mappedTexture2D = devices.DeviceDirect3D.ImmediateContext.MapSubresource(singleTextures[texIndex], mipLevel, 0, MapMode.Read, SharpDX.Direct3D11.MapFlags.None, out stream);



mipLevel is 0 for the first pass.



I don't understand why the method uses 'out stream', because a stream isn't required at all, and a DataBox is returned. So I just pass in an unused Stream object to satisfy the method.



The texture seems ok to me ...


ArraySize = 1

BindFlags = ShaderResource

CPUAccessFlags = None

Format = R8G8B8A8_UNorm

Height = 128

MipLevels = 1

OptionFlags = None

SampleDescription = {1, 0}

Usage = Immutable

Width = 128



Any ideas as to what I'm doing wrong ?











Share this post

Link to post
Share on other sites

You can't just map any texture and read the data. You can only do it for textures created with STAGING usage, and that also specify that have CPU read access. Staging textures can't actually be used for rendering, generally what you will do is use CopyResource to copy the contents from a normal texture to a staging texture and then you'll map the staging texture to read the contents.

In general you should make sure that you create your device with the DEBUG flag set, and watch the native debugger output for errors and warnings. The debug device will give you detailed error messages for cases like this.

Share this post

Link to post
Share on other sites

Ahh, looking back at my SlimDX code I can see that I had used Staging in my ImageLoadInformation, but in SharpDX it doesn't have any variables except default, so I've just commented it out. Thanks for the reminder.


And I didn't have debug setup correctly, so thanks for getting me to check that as well. I only had it set for 2d.

Edited by Gavin Williams

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement