1

Closed

[DDSTextureLoader] ID3D11Context::Map fails

description

Hi developers.

I am creating a DDS texture in the following way:
HRESULT result = CreateDDSTextureFromFile(device, L"aTexture.dds", &myID3D11Resource, &myShaderResourceView);

HRESULT is OK, but when I execute the following code:
    D3D11_MAPPED_SUBRESOURCE mappedSubresource;
    result = context->Map(myID3D11Resource, 0, D3D11_MAP_READ, 0, &mappedSubresource);
I get the error code E_INVALID_ARG.

I was researching and the problem is that Map assumes that the resource has been created with read access at least (D3D11_MAP_READ).

So I modified code inside DDSTextureLoader.cpp. For test purposes I added an argument to CreateDDSTextureFromFile and FromMemory to choose cpuAccessFlags (attached files have this modifications). Basically I changed:

desc.CPUAccessFlags = cpuAccessFlags; where cpuAccessFlags is an UINT argument.

The problem of my modification is that when I execute again:

HRESULT result = CreateDDSTextureFromFile(device, L"aTexture.dds", &myID3D11Resource, &myShaderResourceView, D3D11_CPU_READ);

I got the error code E_INVALID_ARGS at this point (i.e. before ID3D11Context::Map function)

So, is there a solution? a workaround? is this a bug? I am needing to do this because I want to Map textures into a textureArray to be able to use texture2DArray in HLSL.

Thanks!

file attachments

Closed Oct 23, 2012 at 2:35 AM by ShawnHargreaves
This is a duplicate of issue 817

comments