Jump to content
  • Advertisement
Sign in to follow this  

DirectX10?. How should I go about copying a ID3D10ShaderResourceView to an array of

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

First off, Nice new look.

ok my problem is that I have a Texture2DArray g_tx2dArray in my shader, I can load this and it works fine.
But now I would like to change its image data at runtime.
I was doing this Device->CopySubresourceRegion(destrc,0, 0, 0, 0, pdecalResource,0, NULL);

this works but only when the new resource is the same size or fits in the previous resource.

What would be the best way to copy the lager image to the resource I cant find anything on doing this, may be this

void [color="#ffffff"]UpdateSubresource( ID3D10Resource *pDstResource, UINT DstSubresource, const D3D10_BOX *pDstBox, const void *pSrcData, UINT SrcRowPitch, UINT SrcDepthPitch);

but I dont know how to get the SrcRowPitch.
I only have the resourceView and I cant get the image size for some reason all I can get is GetDesc which has this data but no image width and height

D3D10_SHADER_RESOURCE_VIEW_DESC { DXGI_FORMAT Format; D3D10_SRV_DIMENSION ViewDimension; union { D3D10_BUFFER_SRV Buffer; D3D10_TEX1D_SRV Texture1D; D3D10_TEX1D_ARRAY_SRV Texture1DArray; D3D10_TEX2D_SRV Texture2D; D3D10_TEX2D_ARRAY_SRV Texture2DArray; D3D10_TEX2DMS_SRV Texture2DMS; D3D10_TEX2DMS_ARRAY_SRV Texture2DMSArray; D3D10_TEX3D_SRV Texture3D; D3D10_TEXCUBE_SRV TextureCube; };

and whats with the text here. copy and pased should convert the text to whats being used.

Share this post

Link to post
Share on other sites
A thought on the issue.
I know now why what I was asking was impossible with out creating a new view for that size(working on it to long).

What about this idea if I have a valid ID3D10ShaderResourceView* which I do, could i some how set these pointers directly, some thing like this
ShaderResourceViewArry[0] = resouretoset;//allready loaded and is a valid view."you can't do it this way"
but I dont know how to acsses the array members, can not find them.

I think I will just have to set one size for all images .:unsure:

Share this post

Link to post
Share on other sites
Be sure that your source box for CopySubResourceRegion() is always less than equal to your destination size.

UpdateSubResource allows you to copy data from the CPU to the GPU. Row pitch should be the number of bytes in one row of a texture. Depth pitch is the number of bytes in one slice of a 3d texture. They can be zero if unused. Since the data is coming from the CPU side you should be able to calculate this yourself.

From a SRV you can call QueryInterface() for the ID3DTexture object the SRV was created from. From there you can call GetDesc() to get the dimensions.

Share this post

Link to post
Share on other sites
Having some issues with using UpdateSubresource I think the issue may be with the rowpitch not sure.
here is the code I'm using.
[color="#008000"][color="#008000"]//set the decals to the array for the shader

ID3D10Resource *pdecalResource = NULL;


ID3D10Resource *destrc = NULL;


[color="#008000"][color="#008000"]//D3D10_SHADER_RESOURCE_VIEW_DESC desc;


[color="#008000"][color="#008000"]//D3D10_TEXTURE2D_DESC ddisc;


ID3D10Texture2D *texdecal = NULL;

HRESULT hr = pdecalResource->QueryInterface( [color="#0000ff"][color="#0000ff"]__uuidof( ID3D10Texture2D ), (LPVOID*)&texdecal);





D3D10_BOX destRegion;

destRegion.left = 0;

destRegion.right = 64;[color="#008000"][color="#008000"]//desc.Width;

destRegion.top = 0;

destRegion.bottom = 32;[color="#008000"][color="#008000"]//desc.Height;

destRegion.front = 0;

destRegion.back = 1;

UINT bytecount =4;// GetDXGI_FORMAT_BitCount(desc.Format)/8;[color="#008000"][color="#008000"]//we need bytes not bits

UINT rowpitch = desc.Width * bytecount;

UINT depthpitch = rowpitch * desc.Height ;

Device->UpdateSubresource(destrc,0 , &destRegion, pdecalResource, rowpitch, depthpitch);


[color="#008000"][color="#008000"]//Device->CopySubresourceRegion(destrc,0, 0, 0, 0, pdecalResource,0, NULL);




Image of problem.

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!