Permalink
Browse files

GPU: Use HW transform for flat spline/bezier.

We can control the provoking vertex here, but it's less likely to matter.
  • Loading branch information...
unknownbrackets committed Jun 29, 2018
1 parent 5abf324 commit 9bac60397646bfd49d955ded47db4a835b3ccf94
Showing with 8 additions and 6 deletions.
  1. +5 −4 GPU/D3D11/DrawEngineD3D11.cpp
  2. +2 −1 GPU/Directx9/ShaderManagerDX9.cpp
  3. +1 −1 GPU/Vulkan/DrawEngineVulkan.cpp
@@ -325,14 +325,15 @@ void DrawEngineD3D11::DoFlush() {
gpuStats.numFlushes++;
gpuStats.numTrackedVertexArrays = (int)vai_.size();
// This is not done on every drawcall, we should collect vertex data
// This is not done on every drawcall, we collect vertex data
// until critical state changes. That's when we draw (flush).
GEPrimitiveType prim = prevPrim_;
ApplyDrawState(prim);
// Always use software for flat shading to fix the provoking index.
bool useHWTransform = CanUseHardwareTransform(prim) && gstate.getShadeMode() != GE_SHADE_FLAT;
bool tess = gstate_c.bezier || gstate_c.spline;
bool useHWTransform = CanUseHardwareTransform(prim) && (tess || gstate.getShadeMode() != GE_SHADE_FLAT);
if (useHWTransform) {
ID3D11Buffer *vb_ = nullptr;
@@ -539,7 +540,7 @@ void DrawEngineD3D11::DoFlush() {
memcpy(iptr, decIndex, iSize);
pushInds_->EndPush(context_);
context_->IASetIndexBuffer(pushInds_->Buf(), DXGI_FORMAT_R16_UINT, iOffset);
if (gstate_c.bezier || gstate_c.spline)
if (tess)
context_->DrawIndexedInstanced(vertexCount, numPatches, 0, 0, 0);
else
context_->DrawIndexed(vertexCount, 0, 0);
@@ -551,7 +552,7 @@ void DrawEngineD3D11::DoFlush() {
context_->IASetVertexBuffers(0, 1, &vb_, &stride, &offset);
if (useElements) {
context_->IASetIndexBuffer(ib_, DXGI_FORMAT_R16_UINT, 0);
if (gstate_c.bezier || gstate_c.spline)
if (tess)
context_->DrawIndexedInstanced(vertexCount, numPatches, 0, 0, 0);
else
context_->DrawIndexed(vertexCount, 0, 0);
@@ -538,7 +538,8 @@ void ShaderManagerDX9::DirtyLastShader() { // disables vertex arrays
VSShader *ShaderManagerDX9::ApplyShader(int prim, u32 vertType) {
// Always use software for flat shading to fix the provoking index.
bool useHWTransform = CanUseHardwareTransform(prim) && gstate.getShadeMode() != GE_SHADE_FLAT;
bool tess = gstate_c.bezier || gstate_c.spline;
bool useHWTransform = CanUseHardwareTransform(prim) && (tess || gstate.getShadeMode() != GE_SHADE_FLAT);
VShaderID VSID;
if (gstate_c.IsDirty(DIRTY_VERTEXSHADER_STATE)) {
@@ -578,7 +578,7 @@ void DrawEngineVulkan::DoFlush() {
GEPrimitiveType prim = prevPrim_;
// Always use software for flat shading to fix the provoking index.
bool useHWTransform = CanUseHardwareTransform(prim) && gstate.getShadeMode() != GE_SHADE_FLAT;
bool useHWTransform = CanUseHardwareTransform(prim) && (tess || gstate.getShadeMode() != GE_SHADE_FLAT);
VulkanVertexShader *vshader = nullptr;
VulkanFragmentShader *fshader = nullptr;

0 comments on commit 9bac603

Please sign in to comment.