So I know that a texture that has been created with D3D11_CPU_ACCESS_READ cant be put in the pipeline.
What i wanna do is render to a 1DTexture1x1 and then read the pixel in the CPU, how can i do that?
reading a 1DTexture1x1 in CPU after rendering to it in pipeline
Started by lomateron, Aug 31 2012 01:21 AM
5 replies to this topic
Sponsor:
#3 Members - Reputation: 198
Posted 31 August 2012 - 09:11 AM
I have a stupidly hard problem, look at the fourth parameter of the method map()
[source lang="java"]HRESULT Map( [in] UINT Subresource, [in] D3D10_MAP MapType, [in] UINT MapFlags, [out] void **ppData)[/source]
so the data is in a single pixel, so i have:
D3DXVECTOR4 pix;
how do i put that pixel info in pix, i mean pix=.......?;
My brain gets stuck and ends in pure confusion when i think about pointers that point to other pointer and equals to another pointer that points another
... Have read again all about pointers and have tried but i cant still do it.
[source lang="java"]HRESULT Map( [in] UINT Subresource, [in] D3D10_MAP MapType, [in] UINT MapFlags, [out] void **ppData)[/source]
so the data is in a single pixel, so i have:
D3DXVECTOR4 pix;
how do i put that pixel info in pix, i mean pix=.......?;
My brain gets stuck and ends in pure confusion when i think about pointers that point to other pointer and equals to another pointer that points another
#4 Members - Reputation: 1987
Posted 31 August 2012 - 09:19 AM
void *pData;
Map(subres, D3D10_MAP_READ, 0, &pData);
D3DXVECTOR4 *pPix = reinterpret_cast<D3DXVECTOR4*>(pData);
D3DXVECTOR4 pix = *pPix;
This requires that your 1x1 texture is in a 128-bit float format ofcourse, as D3DXVECTOR4 is 4 floats.
Otherwise you need to convert it. For example if you have a normal R8G8B8A8 resource you can use pData as an unsigned char[4] to get the R G B A components from 0 to 255.
Map(subres, D3D10_MAP_READ, 0, &pData);
D3DXVECTOR4 *pPix = reinterpret_cast<D3DXVECTOR4*>(pData);
D3DXVECTOR4 pix = *pPix;
This requires that your 1x1 texture is in a 128-bit float format ofcourse, as D3DXVECTOR4 is 4 floats.
Otherwise you need to convert it. For example if you have a normal R8G8B8A8 resource you can use pData as an unsigned char[4] to get the R G B A components from 0 to 255.
Edited by Erik Rufelt, 31 August 2012 - 09:23 AM.






