- load all the shaders and use the right one for each renderpass
This commit is contained in:
parent
f1f8797d3c
commit
d4118a755c
11 changed files with 173 additions and 64 deletions
|
|
@ -138,8 +138,18 @@ void VkRenderPassSetup::CreatePipeline(const VkRenderPassKey &key)
|
|||
{
|
||||
auto fb = GetVulkanFrameBuffer();
|
||||
GraphicsPipelineBuilder builder;
|
||||
builder.addVertexShader(fb->GetShaderManager()->vert.get());
|
||||
builder.addFragmentShader(fb->GetShaderManager()->frag.get());
|
||||
|
||||
VkShaderProgram *program;
|
||||
if (key.SpecialEffect != EFF_NONE)
|
||||
{
|
||||
program = fb->GetShaderManager()->GetEffect(key.SpecialEffect);
|
||||
}
|
||||
else
|
||||
{
|
||||
program = fb->GetShaderManager()->Get(key.EffectState, key.AlphaTest);
|
||||
}
|
||||
builder.addVertexShader(program->vert.get());
|
||||
builder.addFragmentShader(program->frag.get());
|
||||
|
||||
builder.addVertexBufferBinding(0, sizeof(F2DDrawer::TwoDVertex));
|
||||
builder.addVertexAttribute(0, 0, VK_FORMAT_R32G32B32_SFLOAT, offsetof(F2DDrawer::TwoDVertex, x));
|
||||
|
|
|
|||
|
|
@ -11,10 +11,15 @@ class VkRenderPassKey
|
|||
{
|
||||
public:
|
||||
FRenderStyle RenderStyle;
|
||||
int SpecialEffect;
|
||||
int EffectState;
|
||||
bool AlphaTest;
|
||||
|
||||
bool operator<(const VkRenderPassKey &other) const
|
||||
{
|
||||
return RenderStyle.AsDWORD < other.RenderStyle.AsDWORD;
|
||||
uint64_t a = RenderStyle.AsDWORD | (static_cast<uint64_t>(SpecialEffect) << 32) | (static_cast<uint64_t>(EffectState) << 40) | (static_cast<uint64_t>(AlphaTest) << 48);
|
||||
uint64_t b = other.RenderStyle.AsDWORD | (static_cast<uint64_t>(other.SpecialEffect) << 32) | (static_cast<uint64_t>(other.EffectState) << 40) | (static_cast<uint64_t>(other.AlphaTest) << 48);
|
||||
return a < b;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -148,6 +148,19 @@ void VkRenderState::Apply(int dt)
|
|||
// Find a render pass that matches our state
|
||||
VkRenderPassKey passKey;
|
||||
passKey.RenderStyle = mRenderStyle;
|
||||
if (mSpecialEffect > EFF_NONE)
|
||||
{
|
||||
passKey.SpecialEffect = mSpecialEffect;
|
||||
passKey.EffectState = 0;
|
||||
passKey.AlphaTest = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int effectState = mMaterial.mOverrideShader >= 0 ? mMaterial.mOverrideShader : (mMaterial.mMaterial ? mMaterial.mMaterial->GetShaderIndex() : 0);
|
||||
passKey.SpecialEffect = EFF_NONE;
|
||||
passKey.EffectState = mTextureEnabled ? effectState : SHADER_NoTexture;
|
||||
passKey.AlphaTest = mAlphaThreshold >= 0.f;
|
||||
}
|
||||
VkRenderPassSetup *passSetup = passManager->GetRenderPass(passKey);
|
||||
|
||||
// Is this the one we already have or do we need to change render pass?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue