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:
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.