D3D11/12 mipmapping fixes

This commit is contained in:
Jack Andersen 2016-01-19 10:30:51 -10:00
parent c8b72e8bef
commit 2f254dc955
3 changed files with 100 additions and 95 deletions

View File

@ -121,8 +121,8 @@ class D3D11TextureS : public ITextureS
friend class D3D11DataFactory;
size_t m_sz;
D3D11TextureS(D3D11Context* ctx, size_t width, size_t height, size_t mips,
TextureFormat fmt, const void* data, size_t sz)
: m_sz(sz)
TextureFormat fmt, const void* data, size_t sz)
: m_sz(sz)
{
CD3D11_TEXTURE2D_DESC desc(DXGI_FORMAT_R8G8B8A8_UNORM, width, height, 1, mips,
D3D11_BIND_SHADER_RESOURCE, D3D11_USAGE_IMMUTABLE);
@ -141,7 +141,7 @@ class D3D11TextureS : public ITextureS
ThrowIfFailed(ctx->m_dev->CreateTexture2D(&desc, upData, &m_tex));
ThrowIfFailed(ctx->m_dev->CreateShaderResourceView(m_tex.Get(),
&CD3D11_SHADER_RESOURCE_VIEW_DESC(m_tex.Get(), D3D_SRV_DIMENSION_TEXTURE2D, DXGI_FORMAT_R8G8B8A8_UNORM), &m_srv));
&CD3D11_SHADER_RESOURCE_VIEW_DESC(m_tex.Get(), D3D_SRV_DIMENSION_TEXTURE2D, DXGI_FORMAT_R8G8B8A8_UNORM, 0, mips), &m_srv));
}
public:
ComPtr<ID3D11Texture2D> m_tex;

View File

@ -199,7 +199,8 @@ public:
D3D12_RESOURCE_STATE_COPY_DEST,
nullptr, __uuidof(ID3D12Resource), &m_gpuTex));
CommandSubresourcesTransfer<16>(ctx->m_dev.Get(), ctx->m_loadlist.Get(), m_gpuTex.Get(), m_tex.Get(), 0, 0, m_gpuDesc.MipLevels);
CommandSubresourcesTransfer<16>(ctx->m_dev.Get(), ctx->m_loadlist.Get(), m_gpuTex.Get(),
m_tex.Get(), 0, 0, m_gpuDesc.MipLevels);
ctx->m_loadlist->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_gpuTex.Get(),
D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE));
@ -1491,7 +1492,7 @@ public:
texDescs.reserve(retval->m_STexs.size() + retval->m_SATexs.size() + retval->m_DTexs.size() * 2);
for (std::unique_ptr<D3D12GraphicsBufferS>& buf : retval->m_SBufs)
bufDescs.push_back(buf->m_buf->GetDesc());
bufDescs.push_back(buf->m_gpuDesc);
for (std::unique_ptr<D3D12GraphicsBufferD>& buf : retval->m_DBufs)
{
@ -1500,15 +1501,15 @@ public:
}
for (std::unique_ptr<D3D12TextureS>& tex : retval->m_STexs)
texDescs.push_back(tex->m_tex->GetDesc());
texDescs.push_back(tex->m_gpuDesc);
for (std::unique_ptr<D3D12TextureSA>& tex : retval->m_SATexs)
texDescs.push_back(tex->m_tex->GetDesc());
texDescs.push_back(tex->m_gpuDesc);
for (std::unique_ptr<D3D12TextureD>& tex : retval->m_DTexs)
{
texDescs.push_back(tex->m_texs[0]->GetDesc());
texDescs.push_back(tex->m_texs[1]->GetDesc());
texDescs.push_back(tex->m_gpuDesc);
texDescs.push_back(tex->m_gpuDesc);
}
/* Create heap */

View File

@ -211,7 +211,11 @@ public:
adapter->GetParent(__uuidof(IDXGIFactory2), &m_3dCtx.m_ctx11.m_dxFactory);
/* Build default sampler here */
m_3dCtx.m_ctx11.m_dev->CreateSamplerState(&CD3D11_SAMPLER_DESC(D3D11_DEFAULT), &m_3dCtx.m_ctx11.m_ss);
CD3D11_SAMPLER_DESC sampDesc(D3D11_DEFAULT);
sampDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
sampDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
sampDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
m_3dCtx.m_ctx11.m_dev->CreateSamplerState(&sampDesc, &m_3dCtx.m_ctx11.m_ss);
Log.report(LogVisor::Info, "initialized D3D11 renderer");
return;