This commit is contained in:
Jack Andersen 2016-07-31 18:32:27 -10:00
parent 21548bada8
commit 29364a8024
3 changed files with 38 additions and 40 deletions

View File

@ -15,19 +15,19 @@ constexpr type operator&(type a, type b)\
using T = std::underlying_type_t<type>;\ using T = std::underlying_type_t<type>;\
return type(static_cast<T>(a) & static_cast<T>(b));\ return type(static_cast<T>(a) & static_cast<T>(b));\
}\ }\
constexpr type& operator|=(type& a, const type& b)\ inline type& operator|=(type& a, const type& b)\
{\ {\
using T = std::underlying_type_t<type>;\ using T = std::underlying_type_t<type>;\
a = type(static_cast<T>(a) | static_cast<T>(b));\ a = type(static_cast<T>(a) | static_cast<T>(b));\
return a;\ return a;\
}\ }\
constexpr type& operator&=(type& a, const type& b)\ inline type& operator&=(type& a, const type& b)\
{\ {\
using T = std::underlying_type_t<type>;\ using T = std::underlying_type_t<type>;\
a = type(static_cast<T>(a) & static_cast<T>(b));\ a = type(static_cast<T>(a) & static_cast<T>(b));\
return a;\ return a;\
}\ }\
constexpr type operator~(const type& key)\ inline type operator~(const type& key)\
{\ {\
using T = std::underlying_type_t<type>;\ using T = std::underlying_type_t<type>;\
return type(~static_cast<T>(key));\ return type(~static_cast<T>(key));\

View File

@ -500,7 +500,7 @@ class D3D11ShaderPipeline : public IShaderPipeline
CD3D11_DEPTH_STENCIL_DESC dsDesc(D3D11_DEFAULT); CD3D11_DEPTH_STENCIL_DESC dsDesc(D3D11_DEFAULT);
dsDesc.DepthEnable = depthTest; dsDesc.DepthEnable = depthTest;
dsDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK(depthWrite); dsDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK(depthWrite);
dsDesc.DepthFunc = D3D11_COMPARISON_GREATER; dsDesc.DepthFunc = D3D11_COMPARISON_GREATER_EQUAL;
ThrowIfFailed(ctx->m_dev->CreateDepthStencilState(&dsDesc, &m_dsState)); ThrowIfFailed(ctx->m_dev->CreateDepthStencilState(&dsDesc, &m_dsState));
CD3D11_BLEND_DESC blDesc(D3D11_DEFAULT); CD3D11_BLEND_DESC blDesc(D3D11_DEFAULT);
@ -595,10 +595,6 @@ struct D3D11ShaderDataBinding : IShaderDataBinding
} }
for (size_t i=0 ; i<texCount ; ++i) for (size_t i=0 ; i<texCount ; ++i)
{ {
#ifndef NDEBUG
if (!texs[i])
Log.report(logvisor::Fatal, "null texture %d provided to newShaderDataBinding", int(i));
#endif
m_texs[i] = texs[i]; m_texs[i] = texs[i];
} }
} }
@ -747,35 +743,38 @@ struct D3D11ShaderDataBinding : IShaderDataBinding
if (m_texCount) if (m_texCount)
{ {
ID3D11ShaderResourceView* srvs[8]; ID3D11ShaderResourceView* srvs[8] = {};
for (int i=0 ; i<8 && i<m_texCount ; ++i) for (int i=0 ; i<8 && i<m_texCount ; ++i)
{ {
switch (m_texs[i]->type()) if (m_texs[i])
{ {
case TextureType::Dynamic: switch (m_texs[i]->type())
{ {
D3D11TextureD* ctex = static_cast<D3D11TextureD*>(m_texs[i]); case TextureType::Dynamic:
srvs[i] = ctex->m_srvs[b].Get(); {
break; D3D11TextureD* ctex = static_cast<D3D11TextureD*>(m_texs[i]);
} srvs[i] = ctex->m_srvs[b].Get();
case TextureType::Static: break;
{ }
D3D11TextureS* ctex = static_cast<D3D11TextureS*>(m_texs[i]); case TextureType::Static:
srvs[i] = ctex->m_srv.Get(); {
break; D3D11TextureS* ctex = static_cast<D3D11TextureS*>(m_texs[i]);
} srvs[i] = ctex->m_srv.Get();
case TextureType::StaticArray: break;
{ }
D3D11TextureSA* ctex = static_cast<D3D11TextureSA*>(m_texs[i]); case TextureType::StaticArray:
srvs[i] = ctex->m_srv.Get(); {
break; D3D11TextureSA* ctex = static_cast<D3D11TextureSA*>(m_texs[i]);
} srvs[i] = ctex->m_srv.Get();
case TextureType::Render: break;
{ }
D3D11TextureR* ctex = static_cast<D3D11TextureR*>(m_texs[i]); case TextureType::Render:
srvs[i] = ctex->m_colorSrv.Get(); {
break; D3D11TextureR* ctex = static_cast<D3D11TextureR*>(m_texs[i]);
} srvs[i] = ctex->m_colorSrv.Get();
break;
}
}
} }
} }
ctx->PSSetShaderResources(0, m_texCount, srvs); ctx->PSSetShaderResources(0, m_texCount, srvs);

View File

@ -648,7 +648,7 @@ class D3D12ShaderPipeline : public IShaderPipeline
if (!backfaceCulling) if (!backfaceCulling)
desc.RasterizerState.CullMode = D3D12_CULL_MODE_NONE; desc.RasterizerState.CullMode = D3D12_CULL_MODE_NONE;
desc.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC(D3D12_DEFAULT); desc.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC(D3D12_DEFAULT);
desc.DepthStencilState.DepthFunc = D3D12_COMPARISON_FUNC_GREATER; desc.DepthStencilState.DepthFunc = D3D12_COMPARISON_FUNC_GREATER_EQUAL;
if (!depthTest) if (!depthTest)
desc.DepthStencilState.DepthEnable = false; desc.DepthStencilState.DepthEnable = false;
if (!depthWrite) if (!depthWrite)
@ -935,10 +935,6 @@ struct D3D12ShaderDataBinding : IShaderDataBinding
} }
for (size_t i=0 ; i<texCount ; ++i) for (size_t i=0 ; i<texCount ; ++i)
{ {
#ifndef NDEBUG
if (!texs[i])
Log.report(logvisor::Fatal, "null texture %d provided to newShaderDataBinding", int(i));
#endif
m_texs[i] = texs[i]; m_texs[i] = texs[i];
} }
} }
@ -996,7 +992,7 @@ struct D3D12ShaderDataBinding : IShaderDataBinding
} }
for (size_t i=0 ; i<MAX_TEXTURE_COUNT ; ++i) for (size_t i=0 ; i<MAX_TEXTURE_COUNT ; ++i)
{ {
if (i<m_texCount) if (i<m_texCount && m_texs[i])
{ {
D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc; D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc;
ID3D12Resource* res = GetTextureGPUResource(m_texs[i], b, srvDesc); ID3D12Resource* res = GetTextureGPUResource(m_texs[i], b, srvDesc);
@ -1602,6 +1598,9 @@ public:
{ {
ComPtr<ID3DBlob> errBlob; ComPtr<ID3DBlob> errBlob;
//printf("%s\n", vertSource);
//printf("%s\n", fragSource);
if (!vertBlobOut) if (!vertBlobOut)
{ {
if (FAILED(D3DCompilePROC(vertSource, strlen(vertSource), "HECL Vert Source", nullptr, nullptr, "main", if (FAILED(D3DCompilePROC(vertSource, strlen(vertSource), "HECL Vert Source", nullptr, nullptr, "main",