Jump to content

  • Log In with Google      Sign In   
  • Create Account

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


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
3 replies to this topic

#1 ankhd   Members   -  Reputation: 1282

Like
0Likes
Like

Posted 12 January 2011 - 02:35 AM

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( 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.



Sponsor:

#2 ankhd   Members   -  Reputation: 1282

Like
0Likes
Like

Posted 13 January 2011 - 02:27 AM

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:

#3 DieterVW   Members   -  Reputation: 700

Like
1Likes
Like

Posted 13 January 2011 - 01:44 PM

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.

#4 ankhd   Members   -  Reputation: 1282

Like
0Likes
Like

Posted 15 January 2011 - 07:34 PM

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

ID3D10Resource *pdecalResource = NULL;

decal0->ResourceView->GetResource(&pdecalResource);



ID3D10Resource *destrc = NULL;

g_pLeafTexRV->GetResource(&destrc);

//D3D10_SHADER_RESOURCE_VIEW_DESC desc;

//g_pLeafTexRV->GetDesc(&desc);



//D3D10_TEXTURE2D_DESC ddisc;

//pdecalResource->GetDesc(&ddisc);

ID3D10Texture2D *texdecal = NULL;

HRESULT hr = pdecalResource->QueryInterface(
__uuidof( ID3D10Texture2D ), (LPVOID*)&texdecal);



if(!FAILED(hr))

{

D3D10_TEXTURE2D_DESC desc;

texdecal->GetDesc(&desc);

D3D10_BOX destRegion;

destRegion.left = 0;

destRegion.right = 64;
//desc.Width;

destRegion.top = 0;

destRegion.bottom = 32;
//desc.Height;

destRegion.front = 0;

destRegion.back = 1;



UINT bytecount =4;// GetDXGI_FORMAT_BitCount(desc.Format)/8;
//we need bytes not bits

UINT rowpitch = desc.Width * bytecount;

UINT depthpitch = rowpitch * desc.Height ;

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



}

//Device->CopySubresourceRegion(destrc,0, 0, 0, 0, pdecalResource,0, NULL);



SAFE_RELEASE(texdecal);

SAFE_RELEASE(pdecalResource);

SAFE_RELEASE(destrc);


Image of problem.
Posted Image






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