Jump to content

  • Log In with Google      Sign In   
  • Create Account

reading a 1DTexture1x1 in CPU after rendering to it in pipeline


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

#1 lomateron   Members   -  Reputation: 342

Like
0Likes
Like

Posted 31 August 2012 - 01:21 AM

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?

Sponsor:

#2 Erik Rufelt   Crossbones+   -  Reputation: 3478

Like
0Likes
Like

Posted 31 August 2012 - 02:06 AM

Render it to a D3D11_USAGE_DEFAULT texture and then copy it to a D3D11_USAGE_STAGING texture, which can be created with CPU read access and be read back.
Use CopyResource for the copy.

Edited by Erik Rufelt, 31 August 2012 - 02:07 AM.


#3 lomateron   Members   -  Reputation: 342

Like
0Likes
Like

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 anotherPosted Image ... Have read again all about pointers and have tried but i cant still do it.

#4 Erik Rufelt   Crossbones+   -  Reputation: 3478

Like
0Likes
Like

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.

Edited by Erik Rufelt, 31 August 2012 - 09:23 AM.


#5 lomateron   Members   -  Reputation: 342

Like
0Likes
Like

Posted 31 August 2012 - 09:23 AM

now its correct thanks

Edited by lomateron, 31 August 2012 - 09:27 AM.


#6 lomateron   Members   -  Reputation: 342

Like
0Likes
Like

Posted 31 August 2012 - 09:35 AM

wait i don't know, but does this works too?

D3DXVECTOR4 pix;
collTime2->Map(0, D3D10_MAP_READ, 0, (void**)&pix);

Edited by lomateron, 31 August 2012 - 09:50 AM.





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