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

Started by
2 comments, last by ankhd 13 years, 3 months ago
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 UpdateSubresource(</span> <span style="font-weight:bold;">ID3D10Resource</span> *<span style="font-weight:bold;">pDstResource</span><span style="font-weight:bold;">,</span> <span style="font-weight:bold;">UINT</span> <span style="font-weight:bold;">DstSubresource</span><span style="font-weight:bold;">,</span> <span style="font-weight:bold;">const D3D10_BOX</span> *<span style="font-weight:bold;">pDstBox</span><span style="font-weight:bold;">,</span> <span style="font-weight:bold;">const void</span> *<span style="font-weight:bold;">pSrcData</span><span style="font-weight:bold;">,</span> <span style="font-weight:bold;">UINT</span> <span style="font-weight:bold;">SrcRowPitch</span><span style="font-weight:bold;">,</span> <span style="font-weight:bold;">UINT</span> <span style="font-weight:bold;">SrcDepthPitch</span><span style="font-weight:bold;">)</span>;<br /> <br /> but I dont know how to get the <span style="font-weight:bold;">SrcRowPitch.<br /> </span>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<br /> <br /> <br /> 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; };<br /> <br /> and whats with the text here. copy and pased should convert the text to whats being used.<br /> <br />
Advertisement
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:
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.
Having some issues with using UpdateSubresource I think the issue may be with the rowpitch not sure.
here is the code I'm using.
//set the decals to the array for the shader<br /> <br /> ID3D10Resource *pdecalResource = NULL;<br /> <br /> decal0-&gt;ResourceView-&gt;GetResource(&amp;pdecalResource);<br /> <br /> <br /> <br /> ID3D10Resource *destrc = NULL;<br /> <br /> g_pLeafTexRV-&gt;GetResource(&amp;destrc);<br /> <br /> //D3D10_SHADER_RESOURCE_VIEW_DESC desc;<br /> <br /> //g_pLeafTexRV-&gt;GetDesc(&amp;desc);<br /> <br /> <br /> <br /> //D3D10_TEXTURE2D_DESC ddisc;<br /> <br /> //pdecalResource-&gt;GetDesc(&amp;ddisc);<br /> <br /> ID3D10Texture2D *texdecal = NULL;<br /> <br /> HRESULT hr = pdecalResource-&gt;QueryInterface( __uuidof( ID3D10Texture2D ), (LPVOID*)&amp;texdecal);<br /> <br /> <br /> <br /> if(&#33;FAILED(hr))<br /> <br /> {<br /> <br /> D3D10_TEXTURE2D_DESC desc;<br /> <br /> texdecal-&gt;GetDesc(&amp;desc);<br /> <br /> D3D10_BOX destRegion;<br /> <br /> destRegion.left = 0;<br /> <br /> destRegion.right = 64;//desc.Width;<br /> <br /> destRegion.top = 0;<br /> <br /> destRegion.bottom = 32;//desc.Height;<br /> <br /> destRegion.front = 0;<br /> <br /> destRegion.back = 1;<br /> <br /> <br /> <br /> UINT bytecount =4;// GetDXGI_FORMAT_BitCount(desc.Format)/8;//we need bytes not bits<br /> <br /> UINT rowpitch = desc.Width * bytecount;<br /> <br /> UINT depthpitch = rowpitch * desc.Height ;<br /> <br /> Device-&gt;UpdateSubresource(destrc,0 , &amp;destRegion, pdecalResource, rowpitch, depthpitch);<br /> <br /> <br /> <br /> }<br /> <br /> //Device-&gt;CopySubresourceRegion(destrc,0, 0, 0, 0, pdecalResource,0, NULL);<br /> <br /> <br /> <br /> SAFE_RELEASE(texdecal);<br /> <br /> SAFE_RELEASE(pdecalResource);<br /> <br /> SAFE_RELEASE(destrc);<br /> <br /> <br /> Image of problem.<br /> <img src='http://kty8bq.bay.livefilestore.com/y1pSDEQGULAGmP-XvtkySkBKfBpPEbLkQFzH1djhihMFkEsM2ketMhjWUQwGODY0hv85KIZn2_JQHGC7iZaUizhHnwposlmaXCg/LeafMadness.jpg?psid=1' alt='LeafMadness.jpg?psid=1'><br /> <br />

This topic is closed to new replies.

Advertisement