*****SOLUTION******
HRESULT hr;
ID3D11Resource *ppResource;
gGE.TextureList[Texture].m_texture->GetResource(&ppResource);
D3D11_RESOURCE_DIMENSION pResourceDimension;
ppResource->GetType(&pResourceDimension);
auto txt=reinterpret_cast<ID3D11Texture2D*>( ppResource );
D3D11_TEXTURE2D_DESC desc;
txt->GetDesc(&desc);
desc.Usage = D3D11_USAGE_STAGING;
desc.BindFlags = 0;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
ID3D11Texture2D *pTexture = NULL;
hr=gGE.Graphics.dev->CreateTexture2D( &desc, NULL, &pTexture );
if (hr==D3DERR_INVALIDCALL) MessageBoxW(ghWnd,L"Texture Map",L"D3DERR_INVALIDCALL",MB_OK);
if (hr==E_FAIL) MessageBoxW(ghWnd,L"Texture Map",L"E_FAIL",MB_OK);
if (hr==E_INVALIDARG) MessageBoxW(ghWnd,L"Texture Map",L"E_INVALIDARG",MB_OK);
if (hr==E_OUTOFMEMORY) MessageBoxW(ghWnd,L"Texture Map",L"E_OUTOFMEMORY",MB_OK);
if (hr==E_NOTIMPL) MessageBoxW(ghWnd,L"Texture Map",L"E_NOTIMPL",MB_OK);
if (hr==S_FALSE) MessageBoxW(ghWnd,L"Texture Map",L"S_FALSE",MB_OK);
gGE.Graphics.devcon->CopyResource(pTexture,txt);
D3D11_MAPPED_SUBRESOURCE mappedrec;
hr=gGE.Graphics.devcon->Map(pTexture,0,D3D11_MAP_READ,NULL,&mappedrec);
if (FAILED(hr)) MessageBoxW(ghWnd,L"Texture Map",L"mapping failed",MB_OK);
sx=gGE.TextureList[Texture].Width;
sy=gGE.TextureList[Texture].Height;
UINT W=UINT(sx);
UINT H=UINT(sy);
CollisionMap=new byte*[W];
for (UINT i=0;i<W;i++) CollisionMap[i]=new byte[H];
COLOR *C=(COLOR*)mappedrec.pData;
for (UINT x=0;x<W;x++){
for (UINT y=0;y<H;y++){
UINT Loc=(y*W)+x;
CollisionMap[x][y]=C[Loc].a;
}
}
gGE.Graphics.devcon->Unmap(pTexture,0);
pTexture->Release();
The key was in the D3D11_TEXTURE2D_DESC. I had to set the BindFlags to 0 because everything else gave me errors. I suppose that's right. The other two parameters I found from reading LOTS of Microsoft DX11 pages. Also, if you set :
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ|D3D11_CPU_ACCESS_WRITE;
and
hr=gGE.Graphics.devcon->Map(pTexture,0,D3D11_MAP_READ_WRITE,NULL,&mappedrec);
you can do both read and write to that texture (resource)......