Jump to content
  • Advertisement
Sign in to follow this  
BlackJoker

Copy Non-MSAA texture to MSAA texture

This topic is 829 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all,

I want to draw some pixels of the rendertarget texture with different color.

For that I must create staging texture, update data and then copy texture to rendertarget.

The issue is that my rendertarget has MSAA, but staging textures can`t be created with MSAA.

So, my option is to use resolvesubresource, but that method doesnt want to copy texture if it has non default usage.

 

I can create another texture without MSAA, then create staging texture from it and then copy rendertarget texture with resolvesubresource. That will let me get texture data and change pixel colors, but how do I copy Non-MSAA texture back to MSAA texture?

 

I didnt find any solution for that yet except not using MSAA rendertarget, but that no good option for me. Maybe there are some another way to solve this issue?

 

Share this post


Link to post
Share on other sites
Advertisement

I did something similar in C++ and HLSL.

I had to copy entire non-MSAA texture to MSAA backbuffer (both with the same resolution)

 

I did not found a better solution, so I just copying pixel-by-pixel.

 

1. Vertex shader: just render full-screen quad (4 points).

 

2. Pixel shader:

- non-MSAA was bound as SRV, (in hlsl - Texture2D)

Texture2D<float4> ColorTexture : register(t0); //non-MSAA

float4 main(float4 position : SV_Position) : SV_Target
{
    int3 texCoord = int3(position.xy, 0);

    return ColorTexture.Load(texCoord);
}

Update: probably depth test was off (I can't check it right now)

Edited by Happy SDE

Share this post


Link to post
Share on other sites
What about:

- Render stuff to a MS texture
- Resolve to staged not-MS texture
- Copy staged not-MS texture to SwapChain

But I wouldn't do that. Staged textures are very ineficient since they need to be kept in RAM memory.

Share this post


Link to post
Share on other sites

I already render stuff to MS texture and I want to output that texture by applying it on some rectangle. I dont have swapchain in this case.

Also staged textures could not be resolved as I write before. They can be only copied, but because staging could not have MS, I cannot copy it to my rendertarget.

Share this post


Link to post
Share on other sites

I already render stuff to MS texture and I want to output that texture by applying it on some rectangle. I dont have swapchain in this case.
Also staged textures could not be resolved as I write before. They can be only copied, but because staging could not have MS, I cannot copy it to my rendertarget.

Okay, so could you tell us what exactly you need to achieve and why do you need to "draw some pixels of the rendertarget texture with different color" manually? That would help us a lot.

Share this post


Link to post
Share on other sites

I want to do that for cases when I need just to draw separate pixels with separate color (fill bitmap with pixels to display Perlin noise for ex.) and not use small 1 pixel size rectangles for that.

Share this post


Link to post
Share on other sites

I want to do that for cases when I need just to draw separate pixels with separate color (fill bitmap with pixels to display Perlin noise for ex.) and not use small 1 pixel size rectangles for that.


Okay... If I were you I would use a shader, even if you just need a 1x1 rectangle because a staging texture may hit performance too hard. This is just a suggestion because I have no idea about what you could do instead anymore.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!