oit: Can't discard pixel in pixel shader when using 2ndary accumulator
When using the secondary accumulator as source or destination, pixel must not be discarded even if blending results in a nop. Doing so cancels the transfer to/from the accumulator. Issue #979 dx11 oit: use FAILED to detect pixel shader creation error. Log error codes when Buffers::init fails.
This commit is contained in:
parent
e6bc36e110
commit
9f2ffd102c
|
@ -45,7 +45,7 @@ public:
|
|||
}
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN_LOG(RENDERER, "Pixels buffer creation failed");
|
||||
WARN_LOG(RENDERER, "Pixels buffer creation failed: %x", hr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public:
|
|||
|
||||
hr = device->CreateUnorderedAccessView(pixelsBuffer, &uaView, &pixelsBufferView.get());
|
||||
if (FAILED(hr))
|
||||
WARN_LOG(RENDERER, "Pixels buffer UAV creation failed");
|
||||
WARN_LOG(RENDERER, "Pixels buffer UAV creation failed: %x", hr);
|
||||
}
|
||||
|
||||
void resize(int width, int height)
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
HRESULT hr = device->CreateTexture2D(&desc, nullptr, &abufferPointersTex.get());
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN_LOG(RENDERER, "A-buffer texture creation failed");
|
||||
WARN_LOG(RENDERER, "A-buffer texture creation failed: %x", hr);
|
||||
return;
|
||||
}
|
||||
D3D11_UNORDERED_ACCESS_VIEW_DESC uaView{};
|
||||
|
@ -93,7 +93,7 @@ public:
|
|||
|
||||
hr = device->CreateUnorderedAccessView(abufferPointersTex, &uaView, &abufferPointersView.get());
|
||||
if (FAILED(hr))
|
||||
WARN_LOG(RENDERER, "A-buffer texture UAV creation failed");
|
||||
WARN_LOG(RENDERER, "A-buffer texture UAV creation failed: %x", hr);
|
||||
}
|
||||
|
||||
void bind()
|
||||
|
|
|
@ -527,61 +527,6 @@ PSO main(in VertexIn inpix)
|
|||
#if PASS == PASS_COLOR
|
||||
pso.col = color;
|
||||
#elif PASS == PASS_OIT
|
||||
// Discard as many pixels as possible
|
||||
switch (cur_blend_mode.y) // DST
|
||||
{
|
||||
case ONE:
|
||||
switch (cur_blend_mode.x) // SRC
|
||||
{
|
||||
case ZERO:
|
||||
discard;
|
||||
break;
|
||||
case ONE:
|
||||
case OTHER_COLOR:
|
||||
case INVERSE_OTHER_COLOR:
|
||||
if (all(color == 0.f))
|
||||
discard;
|
||||
break;
|
||||
case SRC_ALPHA:
|
||||
if (color.a == 0.f || all(color.rgb == 0.f))
|
||||
discard;
|
||||
break;
|
||||
case INVERSE_SRC_ALPHA:
|
||||
if (color.a == 1.0 || all(color.rgb == 0.f))
|
||||
discard;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OTHER_COLOR:
|
||||
if (cur_blend_mode.x == ZERO && all(color == 1.f))
|
||||
discard;
|
||||
break;
|
||||
case INVERSE_OTHER_COLOR:
|
||||
if (cur_blend_mode.x <= SRC_ALPHA && all(color == 0.f))
|
||||
discard;
|
||||
break;
|
||||
case SRC_ALPHA:
|
||||
if ((cur_blend_mode.x == ZERO || cur_blend_mode.x == INVERSE_SRC_ALPHA) && color.a == 1.f)
|
||||
discard;
|
||||
break;
|
||||
case INVERSE_SRC_ALPHA:
|
||||
switch (cur_blend_mode.x) // SRC
|
||||
{
|
||||
case ZERO:
|
||||
case SRC_ALPHA:
|
||||
if (color.a == 0.f)
|
||||
discard;
|
||||
break;
|
||||
case ONE:
|
||||
case OTHER_COLOR:
|
||||
case INVERSE_OTHER_COLOR:
|
||||
if (all(color == 0.f))
|
||||
discard;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
uint2 coords = uint2(inpix.pos.xy);
|
||||
uint idx = getNextPixelIndex();
|
||||
|
||||
|
@ -1126,7 +1071,7 @@ ComPtr<ID3D11PixelShader> DX11OITShaders::compilePS(const char* source, const ch
|
|||
ComPtr<ID3D11PixelShader> shader;
|
||||
if (blob)
|
||||
{
|
||||
if (device->CreatePixelShader(blob->GetBufferPointer(), blob->GetBufferSize(), nullptr, &shader.get()) != S_OK)
|
||||
if (FAILED(device->CreatePixelShader(blob->GetBufferPointer(), blob->GetBufferSize(), nullptr, &shader.get())))
|
||||
ERROR_LOG(RENDERER, "Pixel shader creation failed");
|
||||
}
|
||||
|
||||
|
|
|
@ -388,60 +388,6 @@ void main()
|
|||
#if PASS == PASS_COLOR
|
||||
FragColor = color;
|
||||
#elif PASS == PASS_OIT
|
||||
// Discard as many pixels as possible
|
||||
switch (cur_blend_mode.y) // DST
|
||||
{
|
||||
case ONE:
|
||||
switch (cur_blend_mode.x) // SRC
|
||||
{
|
||||
case ZERO:
|
||||
discard;
|
||||
case ONE:
|
||||
case OTHER_COLOR:
|
||||
case INVERSE_OTHER_COLOR:
|
||||
if (color == vec4(0.0))
|
||||
discard;
|
||||
break;
|
||||
case SRC_ALPHA:
|
||||
if (color.a == 0.0 || color.rgb == vec3(0.0))
|
||||
discard;
|
||||
break;
|
||||
case INVERSE_SRC_ALPHA:
|
||||
if (color.a == 1.0 || color.rgb == vec3(0.0))
|
||||
discard;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OTHER_COLOR:
|
||||
if (cur_blend_mode.x == ZERO && color == vec4(1.0))
|
||||
discard;
|
||||
break;
|
||||
case INVERSE_OTHER_COLOR:
|
||||
if (cur_blend_mode.x <= SRC_ALPHA && color == vec4(0.0))
|
||||
discard;
|
||||
break;
|
||||
case SRC_ALPHA:
|
||||
if ((cur_blend_mode.x == ZERO || cur_blend_mode.x == INVERSE_SRC_ALPHA) && color.a == 1.0)
|
||||
discard;
|
||||
break;
|
||||
case INVERSE_SRC_ALPHA:
|
||||
switch (cur_blend_mode.x) // SRC
|
||||
{
|
||||
case ZERO:
|
||||
case SRC_ALPHA:
|
||||
if (color.a == 0.0)
|
||||
discard;
|
||||
break;
|
||||
case ONE:
|
||||
case OTHER_COLOR:
|
||||
case INVERSE_OTHER_COLOR:
|
||||
if (color == vec4(0.0))
|
||||
discard;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ivec2 coords = ivec2(gl_FragCoord.xy);
|
||||
uint idx = getNextPixelIndex();
|
||||
|
||||
|
|
|
@ -396,60 +396,6 @@ void main()
|
|||
#if PASS == PASS_COLOR
|
||||
FragColor = color;
|
||||
#elif PASS == PASS_OIT
|
||||
// Discard as many pixels as possible
|
||||
switch (cur_blend_mode.y) // DST
|
||||
{
|
||||
case ONE:
|
||||
switch (cur_blend_mode.x) // SRC
|
||||
{
|
||||
case ZERO:
|
||||
discard;
|
||||
case ONE:
|
||||
case OTHER_COLOR:
|
||||
case INVERSE_OTHER_COLOR:
|
||||
if (color == vec4(0.0))
|
||||
discard;
|
||||
break;
|
||||
case SRC_ALPHA:
|
||||
if (color.a == 0.0 || color.rgb == vec3(0.0))
|
||||
discard;
|
||||
break;
|
||||
case INVERSE_SRC_ALPHA:
|
||||
if (color.a == 1.0 || color.rgb == vec3(0.0))
|
||||
discard;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OTHER_COLOR:
|
||||
if (cur_blend_mode.x == ZERO && color == vec4(1.0))
|
||||
discard;
|
||||
break;
|
||||
case INVERSE_OTHER_COLOR:
|
||||
if (cur_blend_mode.x <= SRC_ALPHA && color == vec4(0.0))
|
||||
discard;
|
||||
break;
|
||||
case SRC_ALPHA:
|
||||
if ((cur_blend_mode.x == ZERO || cur_blend_mode.x == INVERSE_SRC_ALPHA) && color.a == 1.0)
|
||||
discard;
|
||||
break;
|
||||
case INVERSE_SRC_ALPHA:
|
||||
switch (cur_blend_mode.x) // SRC
|
||||
{
|
||||
case ZERO:
|
||||
case SRC_ALPHA:
|
||||
if (color.a == 0.0)
|
||||
discard;
|
||||
break;
|
||||
case ONE:
|
||||
case OTHER_COLOR:
|
||||
case INVERSE_OTHER_COLOR:
|
||||
if (color == vec4(0.0))
|
||||
discard;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ivec2 coords = ivec2(gl_FragCoord.xy);
|
||||
uint idx = getNextPixelIndex();
|
||||
|
||||
|
|
Loading…
Reference in New Issue