Sign in to follow this  
meirivry

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

Recommended Posts

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[list]
[*]Copying it to the render view texture
[*]Without using the graphics pipeline.
[/list]
It is possible?
Is there another way of doing it?

Tx,
Meir.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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[/color] targetDesc = [color=blue]new[/color] [color=#2b91af]Texture2DDescription[/color]
{
BindFlags = [color=#2b91af]BindFlags[/color].RenderTarget | [color=#2b91af]BindFlags[/color].ShaderResource,
Format = [color=#2b91af]Format[/color].B8G8R8A8_UNorm,
Width = 500,
Height = 500,
MipLevels = 1,
SampleDescription = [color=blue]new[/color] [color=#2b91af]SampleDescription[/color](1, 0),
Usage = [color=#2b91af]ResourceUsage[/color].Default,
OptionFlags = [color=#2b91af]ResourceOptionFlags[/color].Shared,
CpuAccessFlags = [color=#2b91af]CpuAccessFlags[/color].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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Thanks. It's a good idea [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]. I rendered to it and it works fine!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this