Jump to content
  • Advertisement
Sign in to follow this  
BattleMetalChris

[DX10] Texture dimensions from a resourceview

This topic is 2589 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

Is there any way to extract the texture height and width from an already-created ID3D10ShaderResourceView?

Or can I only do that when I first create the resource? (which is trivial but means I have to pass the dimensions along to wherever I need them)

Share this post


Link to post
Share on other sites
Advertisement

Is there any way to extract the texture height and width from an already-created ID3D10ShaderResourceView?

Or can I only do that when I first create the resource? (which is trivial but means I have to pass the dimensions along to wherever I need them)


You could go through this kind of verbose code:
[source]
ID3D10Resource* resource;
D3D10_SHADER_RESOURCE_VIEW_DESC viewDesc;
view->GetResource(&resource);
view->GetDesc(&viewDesc);
UINT width;
UINT height;
UINT depth;
switch (desc.ViewDimension) {
case D3D10_SRV_DIMENSION_TEXTURE1D:
...
case D3D10_SRV_DIMENSION_TEXTURE2D:
D3D10_TEXTURE2D_DESC desc2D;
((ID3D10Texture2D*)resource)->GetDesc(&desc2D);
width = desc2D.Width;
height = desc2D.Height;
break;
case D3D10_SRV_DIMENSION_TEXTURE3D:
...
}
resource->Release();
[/source]
But I would recommend you to use in your framework a more highlevel class hierarchy that can abstract resource-view together : a GraphicsResource that keeps a ID3D10Resource pointer and for viewable resource a pointer to a ID3D10ShaderResourceView. Then a Texture2D could inherit from GraphicsResource, cache the Width and Height in the interface, so that you don't have to go through the Desc method of the ID3D10Texture2D...etc.

Share this post


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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!