Original Post
After looking through all the threads I could find relating to this topic and failing, it would seem it is now time to ask for some help.
I have a 32bit BGRA buffer that I am binding to a texture:
which I then bind to a ShaderResourceView and set as a shader resource
I render this once and it works just as expected.
Then I try to update the texture..
Right now Im just updating with the same buffer but that wont be the case in reality. After I try to update the texture, the texture is no longer shows up, and nothing shows up anymore. I am not getting any errors related to this from the Debug Device. I feel like I am doing everything correctly. Creating the texture with D3D11_USAGE_DYNAMIC, and D3D11_CPU_ACCESS_WRITE then using Map to update the texture. Everything I read says this is the proper method. Either I missed something, or I am doing it incorrectly.
Any ideas?
I have a 32bit BGRA buffer that I am binding to a texture:
D3D11_TEXTURE2D_DESC td;
td.ArraySize = 1;
td.BindFlags = D3D11_BIND_SHADER_RESOURCE;
td.Usage = D3D11_USAGE_DYNAMIC;
td.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
td.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
td.Height = m_renderBuffer.height;
td.Width = m_renderBuffer.width;
td.MipLevels = 1;
td.MiscFlags = 0;
td.SampleDesc.Count = 1;
td.SampleDesc.Quality = 0;
D3D11_SUBRESOURCE_DATA srd;
srd.pSysMem = m_renderBuffer.buffer;
srd.SysMemPitch = m_renderBuffer.rowspan;
srd.SysMemSlicePitch = 0;
HR(device->CreateTexture2D(&td, &srd, &m_texture));
which I then bind to a ShaderResourceView and set as a shader resource
HR(device->CreateShaderResourceView(m_texture, 0, &m_textureRV));
.
.
deviceContext->PSSetShaderResources(0, 1, &m_textureRV);
I render this once and it works just as expected.
Then I try to update the texture..
HR(deviceContext->Map(m_texture, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource)
mappedResource.pData = (void*)m_renderBuffer.buffer;
mappedResource.RowPitch = m_renderBuffer.rowspan;
mappedResource.DepthPitch = 0;
deviceContext->Unmap(m_texture, 0);
Right now Im just updating with the same buffer but that wont be the case in reality. After I try to update the texture, the texture is no longer shows up, and nothing shows up anymore. I am not getting any errors related to this from the Debug Device. I feel like I am doing everything correctly. Creating the texture with D3D11_USAGE_DYNAMIC, and D3D11_CPU_ACCESS_WRITE then using Map to update the texture. Everything I read says this is the proper method. Either I missed something, or I am doing it incorrectly.
Any ideas?