add gl_wireframe and gl_wireframecolor
This commit is contained in:
parent
d8c0e4284f
commit
c72bad053f
14 changed files with 151 additions and 64 deletions
|
|
@ -302,6 +302,8 @@ std::unique_ptr<VulkanPipeline> VkRenderPassSetup::CreatePipeline(const VkPipeli
|
|||
GraphicsPipelineBuilder builder;
|
||||
builder.Cache(fb->GetRenderPassManager()->GetCache());
|
||||
|
||||
builder.PolygonMode(key.DrawLine ? VK_POLYGON_MODE_LINE : VK_POLYGON_MODE_FILL);
|
||||
|
||||
VkShaderProgram *program = fb->GetShaderManager()->Get(key.ShaderKey);
|
||||
builder.AddVertexShader(program->vert.get());
|
||||
if (program->frag)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ public:
|
|||
uint64_t DepthFunc : 2;
|
||||
uint64_t StencilTest : 1;
|
||||
uint64_t StencilPassOp : 2;
|
||||
uint64_t Unused : 46;
|
||||
uint64_t DrawLine : 1;
|
||||
uint64_t Unused : 45;
|
||||
};
|
||||
uint64_t AsQWORD = 0;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -252,11 +252,7 @@ void VulkanRenderDevice::InitializeState()
|
|||
|
||||
mDescriptorSetManager->Init();
|
||||
|
||||
#ifdef __APPLE__
|
||||
mRenderState = std::make_unique<VkRenderStateMolten>(this);
|
||||
#else
|
||||
mRenderState = std::make_unique<VkRenderState>(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
void VulkanRenderDevice::Update()
|
||||
|
|
|
|||
|
|
@ -71,15 +71,37 @@ void VkRenderState::ClearScreen()
|
|||
mCommandBuffer->draw(4, 1, vertices.second, 0);
|
||||
}
|
||||
|
||||
void VkRenderState::Draw(int dt, int index, int count, bool apply)
|
||||
void VkRenderState::DoDraw(int dt, int index, int count, bool apply)
|
||||
{
|
||||
if (apply || mNeedApply)
|
||||
Apply(dt);
|
||||
#ifdef __APPLE__
|
||||
// moltenvk doesn't support drawing triangle fans
|
||||
if (dt == DT_TriangleFan)
|
||||
{
|
||||
IBuffer* oldIndexBuffer = mIndexBuffer;
|
||||
mIndexBuffer = fb->GetBufferManager()->FanToTrisIndexBuffer.get();
|
||||
|
||||
mCommandBuffer->draw(count, 1, index, 0);
|
||||
if (apply || mNeedApply)
|
||||
Apply(DT_Triangles);
|
||||
else
|
||||
ApplyVertexBuffers();
|
||||
|
||||
mCommandBuffer->drawIndexed((count - 2) * 3, 1, 0, index, 0);
|
||||
|
||||
mIndexBuffer = oldIndexBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
if (apply || mNeedApply)
|
||||
Apply(dt);
|
||||
|
||||
mCommandBuffer->draw(count, 1, index, 0);
|
||||
#ifdef __APPLE__
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void VkRenderState::DrawIndexed(int dt, int index, int count, bool apply)
|
||||
void VkRenderState::DoDrawIndexed(int dt, int index, int count, bool apply)
|
||||
{
|
||||
if (apply || mNeedApply)
|
||||
Apply(dt);
|
||||
|
|
@ -226,10 +248,11 @@ void VkRenderState::ApplyRenderPass(int dt)
|
|||
// Find a pipeline that matches our state
|
||||
VkPipelineKey pipelineKey;
|
||||
pipelineKey.DrawType = dt;
|
||||
pipelineKey.DrawLine = mDrawLine || mWireframe;
|
||||
pipelineKey.VertexFormat = mVertexBuffer ? static_cast<VkHardwareVertexBuffer*>(mVertexBuffer)->VertexFormat : mRSBuffers->Flatbuffer.VertexFormat;
|
||||
pipelineKey.RenderStyle = mRenderStyle;
|
||||
pipelineKey.DepthTest = mDepthTest;
|
||||
pipelineKey.DepthWrite = mDepthTest && mDepthWrite;
|
||||
pipelineKey.DepthTest = mDepthTest && !mWireframe;
|
||||
pipelineKey.DepthWrite = mDepthTest && !mWireframe && mDepthWrite;
|
||||
pipelineKey.DepthFunc = mDepthFunc;
|
||||
pipelineKey.DepthClamp = mDepthClamp;
|
||||
pipelineKey.DepthBias = !(mBias.mFactor == 0 && mBias.mUnits == 0);
|
||||
|
|
@ -247,7 +270,7 @@ void VkRenderState::ApplyRenderPass(int dt)
|
|||
{
|
||||
int effectState = mMaterial.mOverrideShader >= 0 ? mMaterial.mOverrideShader : (mMaterial.mMaterial ? mMaterial.mMaterial->GetShaderIndex() : 0);
|
||||
pipelineKey.ShaderKey.SpecialEffect = EFF_NONE;
|
||||
pipelineKey.ShaderKey.EffectState = mTextureEnabled ? effectState : SHADER_NoTexture;
|
||||
pipelineKey.ShaderKey.EffectState = (mTextureEnabled && !mWireframe) ? effectState : SHADER_NoTexture;
|
||||
if (r_skipmats && pipelineKey.ShaderKey.EffectState >= 3 && pipelineKey.ShaderKey.EffectState <= 4)
|
||||
pipelineKey.ShaderKey.EffectState = 0;
|
||||
pipelineKey.ShaderKey.AlphaTest = mSurfaceUniforms.uAlphaThreshold >= 0.f;
|
||||
|
|
@ -1080,15 +1103,16 @@ void VkRenderState::ApplyLevelMeshPipeline(VulkanCommandBuffer* cmdbuffer, VkPip
|
|||
pipelineKey.ShaderKey.GBufferPass = mRenderTarget.DrawBuffers > 1;
|
||||
|
||||
// State overridden by the renderstate drawing the mesh
|
||||
pipelineKey.DepthTest = mDepthTest;
|
||||
pipelineKey.DepthWrite = mDepthTest && mDepthWrite;
|
||||
pipelineKey.DrawLine = mDrawLine || mWireframe;
|
||||
pipelineKey.DepthTest = mDepthTest && !mWireframe;
|
||||
pipelineKey.DepthWrite = mDepthTest && !mWireframe && mDepthWrite;
|
||||
pipelineKey.DepthClamp = mDepthClamp;
|
||||
pipelineKey.DepthBias = !(mBias.mFactor == 0 && mBias.mUnits == 0);
|
||||
pipelineKey.StencilTest = mStencilTest;
|
||||
pipelineKey.StencilPassOp = mStencilOp;
|
||||
pipelineKey.ColorMask = mColorMask;
|
||||
pipelineKey.CullMode = mCullMode;
|
||||
if (!mTextureEnabled)
|
||||
if (!mTextureEnabled || mWireframe)
|
||||
pipelineKey.ShaderKey.EffectState = SHADER_NoTexture;
|
||||
|
||||
mPipelineKey = pipelineKey;
|
||||
|
|
@ -1110,30 +1134,3 @@ void VkRenderState::ApplyLevelMeshPipeline(VulkanCommandBuffer* cmdbuffer, VkPip
|
|||
cmdbuffer->bindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, layout, 2, descriptors->GetBindlessSet());
|
||||
cmdbuffer->pushConstants(layout, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, (uint32_t)sizeof(PushConstants), &pushConstants);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void VkRenderStateMolten::Draw(int dt, int index, int count, bool apply)
|
||||
{
|
||||
if (dt == DT_TriangleFan)
|
||||
{
|
||||
IBuffer* oldIndexBuffer = mIndexBuffer;
|
||||
mIndexBuffer = fb->GetBufferManager()->FanToTrisIndexBuffer.get();
|
||||
|
||||
if (apply || mNeedApply)
|
||||
Apply(DT_Triangles);
|
||||
else
|
||||
ApplyVertexBuffers();
|
||||
|
||||
mCommandBuffer->drawIndexed((count - 2) * 3, 1, 0, index, 0);
|
||||
|
||||
mIndexBuffer = oldIndexBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (apply || mNeedApply)
|
||||
Apply(dt);
|
||||
|
||||
mCommandBuffer->draw(count, 1, index, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ public:
|
|||
|
||||
// Draw commands
|
||||
void ClearScreen() override;
|
||||
void Draw(int dt, int index, int count, bool apply = true) override;
|
||||
void DrawIndexed(int dt, int index, int count, bool apply = true) override;
|
||||
void DoDraw(int dt, int index, int count, bool apply) override;
|
||||
void DoDrawIndexed(int dt, int index, int count, bool apply) override;
|
||||
|
||||
// Immediate render state change commands. These only change infrequently and should not clutter the render state.
|
||||
bool SetDepthClamp(bool on) override;
|
||||
|
|
@ -105,6 +105,7 @@ protected:
|
|||
VkRenderPassSetup* mPassSetup = nullptr;
|
||||
int mClearTargets = 0;
|
||||
bool mNeedApply = true;
|
||||
bool mDrawLine = false;
|
||||
|
||||
int mScissorX = 0, mScissorY = 0, mScissorWidth = -1, mScissorHeight = -1;
|
||||
int mViewportX = 0, mViewportY = 0, mViewportWidth = -1, mViewportHeight = -1;
|
||||
|
|
@ -154,12 +155,4 @@ protected:
|
|||
} mRenderTarget;
|
||||
|
||||
TArray<uint32_t> mQueryResultsBuffer;
|
||||
};
|
||||
|
||||
class VkRenderStateMolten : public VkRenderState
|
||||
{
|
||||
public:
|
||||
using VkRenderState::VkRenderState;
|
||||
|
||||
void Draw(int dt, int index, int count, bool apply = true) override;
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue