Jump to content

  • Log In with Google      Sign In   
  • Create Account

MapSubresource error


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Gavin Williams   Members   -  Reputation: 664

Like
0Likes
Like

Posted 25 February 2013 - 07:30 PM

Hi,

 

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 ?

 

 

Thanks.

 

 

 

 

 

 

 



Sponsor:

#2 MJP   Moderators   -  Reputation: 11343

Like
3Likes
Like

Posted 25 February 2013 - 07:59 PM

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.



#3 Gavin Williams   Members   -  Reputation: 664

Like
0Likes
Like

Posted 25 February 2013 - 09:19 PM

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, 25 February 2013 - 09:34 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS