How to copy texture with one format to another with different format?

Started by
3 comments, last by meirivry 12 years ago
Hello,

I have two 2D texture resources with the same dimension (500 X 500).
The first one with B32G32R32A32_Float format.
The second with B8G8R8A8_UNorm and is used Render Target.
I want to copy the first one to the second one with format conversion.

My underline aim is to render the first texture by

  • Copying it to the render view texture
  • Without using the graphics pipeline.

It is possible?
Is there another way of doing it?

Tx,
Meir.
Advertisement
If you don't want to use the GPU, then you will have to readback the texture data on the CPU, do the format conversion, and update the contents of the destination texture. I think that D3DX11LoadTextureFromTexture can do this for you.
Thanks for the prompt response.

Is there a way to do that on the GPU.
I'm creating the target texture with the following Texture Description (SlimDX / D3D11):

[color=blue]var targetDesc = [color=blue]new [color=#2b91af]Texture2DDescription
{
BindFlags = [color=#2b91af]BindFlags.RenderTarget | [color=#2b91af]BindFlags.ShaderResource,
Format = [color=#2b91af]Format.B8G8R8A8_UNorm,
Width = 500,
Height = 500,
MipLevels = 1,
SampleDescription = [color=blue]new [color=#2b91af]SampleDescription(1, 0),
Usage = [color=#2b91af]ResourceUsage.Default,
OptionFlags = [color=#2b91af]ResourceOptionFlags.Shared,
CpuAccessFlags = [color=#2b91af]CpuAccessFlags.None,
ArraySize = 1,
};


If I add UnorderedAccess to the BingFlags in the above description I get "invalid parameter" exception when creating the texture.

So, I cannot create a UAV for target texture.
With no UAV I cannot create a Compute Shader to do the work.

Tx,
Meir.
It's a render target, just render to it with a full-screen quad with a pixel shader that samples your source texture. I'm not sure why it fails when you try to create it with the UAV flag, it might be because you're creating it as a shared resource. If you create your device with the DeviceCreationFlags.Debug option then you'll get error and warning messages in the debug output stream. You'll need to enable native debugging or use a program like DebugView to see the messages.
Thanks. It's a good idea smile.png. I rendered to it and it works fine!

This topic is closed to new replies.

Advertisement