Get FLOAT texture from C++ AMP instead of TYPELESS

113 views Asked by At

I want to display an image produced with C++ AMP in an UWP application in the most efficient way possible.

My approach is to move the C++ AMP data into an ID3D11Texture2D that can be displayed in UWP. To do this I'm copying the data to a texture created with:

unsigned int bitsPerScalarElement = 32;
auto ampTexture = Concurrency::graphics::texture<Concurrency::graphics::float_4, 2>(m_width, m_height, bitsPerScalarElement);

This however results in a texture with the DXGI_FORMAT_R32G32B32A32_TYPELESS texture format. I would like this to be DXGI_FORMAT_R32G32B32A32_FLOAT, otherwise UWP will not be able to display it. It complains that "The bitmap pixel format is unsupported".

According to https://blogs.msdn.microsoft.com/nativeconcurrency/2012/07/02/interop-with-direct3d11-textures-in-c-amp/ I should only have to set the bitsPerScalarElement when creating the texture to choose the type, but it is not working for me.

Anyone who can help me here?

Below is a test program to verify the format returned:

#include "pch.h"
#include <iostream>

#include <amp.h>
#include <amp_graphics.h>

#include <d3d11.h>
#include <wrl.h>

int main()
{
    unsigned int bitsPerScalarElement = 32;
    auto ampTexture = Concurrency::graphics::texture<Concurrency::graphics::float_4, 2>(500, 500, bitsPerScalarElement);

    Microsoft::WRL::ComPtr<ID3D11Texture2D> d3dTexture;
    auto hr = Concurrency::graphics::direct3d::get_texture(ampTexture)->QueryInterface(__uuidof(ID3D11Texture2D), (void**)&d3dTexture);
    D3D11_TEXTURE2D_DESC texDesc;
    d3dTexture->GetDesc(&texDesc);

    std::cout << "Format: " << texDesc.Format << "\n";
}

For me this returns 1, which maps to DXGI_FORMAT_R32G32B32A32_TYPELESS according to dxgiformat.h. I'm running on GeForce GTX 1070 driver 416.34.

0

There are 0 answers