Hash :
4e644b33
Author :
Date :
2022-01-22T16:17:46
Vulkan: Remove ProgramExecutableVk back-pointers. This removes the mProgram and mProgramPipeline back-pointers from ProgramExecutableVk. In order to fix this, we needed to refactor the VkPipeline init functions to call through ProgramExecutableVk only instead of passing through ProgramVk. We also needed to move the early fragment shader optimization boolean out from Program. This CL also fixes a few places where the early fragment test optimization boolean wasn't properly updated. Bug: angleproject:3570 Change-Id: Ie4c48087f6eb022e6f0a4dacc2710085165d49e1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3408267 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
//
// Copyright 2017 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ProgramPipelineVk.cpp:
// Implements the class methods for ProgramPipelineVk.
//
#include "libANGLE/renderer/vulkan/ProgramPipelineVk.h"
#include "libANGLE/renderer/glslang_wrapper_utils.h"
#include "libANGLE/renderer/vulkan/GlslangWrapperVk.h"
namespace rx
{
ProgramPipelineVk::ProgramPipelineVk(const gl::ProgramPipelineState &state)
: ProgramPipelineImpl(state)
{}
ProgramPipelineVk::~ProgramPipelineVk() {}
void ProgramPipelineVk::destroy(const gl::Context *context)
{
ContextVk *contextVk = vk::GetImpl(context);
reset(contextVk);
}
void ProgramPipelineVk::reset(ContextVk *contextVk)
{
mExecutable.reset(contextVk);
}
angle::Result ProgramPipelineVk::link(const gl::Context *glContext,
const gl::ProgramMergedVaryings &mergedVaryings,
const gl::ProgramVaryingPacking &varyingPacking)
{
ContextVk *contextVk = vk::GetImpl(glContext);
const gl::ProgramExecutable &glExecutable = mState.getExecutable();
GlslangSourceOptions options =
GlslangWrapperVk::CreateSourceOptions(contextVk->getRenderer()->getFeatures());
GlslangProgramInterfaceInfo glslangProgramInterfaceInfo;
GlslangWrapperVk::ResetGlslangProgramInterfaceInfo(&glslangProgramInterfaceInfo);
mExecutable.clearVariableInfoMap();
// Now that the program pipeline has all of the programs attached, the various descriptor
// set/binding locations need to be re-assigned to their correct values.
const gl::ShaderType linkedTransformFeedbackStage =
glExecutable.getLinkedTransformFeedbackStage();
// This should be done before assigning varying locations. Otherwise, we can encounter shader
// interface mismatching problems when the transform feedback stage is not the vertex stage.
if (options.supportsTransformFeedbackExtension)
{
for (const gl::ShaderType shaderType : glExecutable.getLinkedShaderStages())
{
const gl::Program *glProgram = mState.getShaderProgram(shaderType);
if (glProgram && gl::ShaderTypeSupportsTransformFeedback(shaderType))
{
const bool isTransformFeedbackStage =
shaderType == linkedTransformFeedbackStage &&
!glProgram->getState().getLinkedTransformFeedbackVaryings().empty();
GlslangAssignTransformFeedbackLocations(
shaderType, glProgram->getState(), isTransformFeedbackStage,
&glslangProgramInterfaceInfo, &mExecutable.mVariableInfoMap);
}
}
}
mExecutable.mOriginalShaderInfo.clear();
gl::ShaderType frontShaderType = gl::ShaderType::InvalidEnum;
UniformBindingIndexMap uniformBindingIndexMap;
for (const gl::ShaderType shaderType : glExecutable.getLinkedShaderStages())
{
const gl::Program *glProgram = mState.getShaderProgram(shaderType);
if (glProgram)
{
const bool isTransformFeedbackStage =
shaderType == linkedTransformFeedbackStage &&
!glProgram->getState().getLinkedTransformFeedbackVaryings().empty();
GlslangAssignLocations(options, glProgram->getState(), varyingPacking, shaderType,
frontShaderType, isTransformFeedbackStage,
&glslangProgramInterfaceInfo, &uniformBindingIndexMap,
&mExecutable.mVariableInfoMap);
frontShaderType = shaderType;
ProgramVk *programVk = vk::GetImpl(glProgram);
ProgramExecutableVk &programExecutableVk = programVk->getExecutable();
mExecutable.mDefaultUniformBlocks[shaderType] =
programExecutableVk.getSharedDefaultUniformBlock(shaderType);
mExecutable.mOriginalShaderInfo.initShaderFromProgram(
shaderType, programExecutableVk.mOriginalShaderInfo);
}
}
mExecutable.setAllDefaultUniformsDirty(glExecutable);
if (contextVk->getFeatures().enablePrecisionQualifiers.enabled)
{
mExecutable.resolvePrecisionMismatch(mergedVaryings);
}
return mExecutable.createPipelineLayout(contextVk, mState.getExecutable(), nullptr);
}
void ProgramPipelineVk::onProgramUniformUpdate(gl::ShaderType shaderType)
{
mExecutable.mDefaultUniformBlocksDirty.set(shaderType);
}
} // namespace rx