Copy Non-MSAA texture to MSAA texture

Started by
6 comments, last by LHLaurini 8 years ago

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?

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)

So, this issue cannot be resolved in code? Only in shader?

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.

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.

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.

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.

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.

This topic is closed to new replies.

Advertisement