Sign in to follow this  

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

Recommended Posts

First off, Nice new look.

ok my problem is that I have a [size="2"]Texture2DArray g_tx2dArray[/size] 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 [size="2"]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

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

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

[/size]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 [size="2"]UpdateSubresource I think the issue may be with the rowpitch not sure.
here is the code I'm using.
[size="2"][color="#008000"][size="2"][color="#008000"]//set the decals to the array for the shader

[/color][/size][/color][/size][size="2"]ID3D10Resource *pdecalResource = NULL;


ID3D10Resource *destrc = NULL;


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


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


[/color][/size][/color][/size][size="2"]ID3D10Texture2D *texdecal = NULL;

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





D3D10_BOX destRegion;

destRegion.left = 0;

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

[/color][/size][/color][/size][size="2"] = 0;

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

[/color][/size][/color][/size][size="2"]destRegion.front = 0;

destRegion.back = 1;

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

[/color][/size][/color][/size][size="2"]UINT rowpitch = desc.Width * bytecount;

UINT depthpitch = rowpitch * desc.Height ;

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


[/size][size="2"][color="#008000"][size="2"][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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this