Commit 68635b43 by Shahbaz Youssefi Committed by Commit Bot

Reland "Vulkan: Move xfb position decl to translator in extension path"

This reverts commit b4b59726. Reason for revert: This was in a chain of reverts, but is unrelated to the issue. Original change's description: > Revert "Vulkan: Move xfb position decl to translator in extension path" > > This reverts commit 8f5ca266. > > Reason for revert: > Earlier CL breaks pre-rotation: > https://chromium-review.googlesource.com/c/angle/angle/+/2598584 > > Original change's description: > > Vulkan: Move xfb position decl to translator in extension path > > > > This change removes the @@ XFB-DECL @@ marker. The ANGLEXfbPosition > > output is unconditionally emitted in VS, TES and GS by the translator, > > and is appropriately decorated or removed by the SPIR-V transformer. > > > > Bug: angleproject:3606 > > Change-Id: Ia76224f5a6d147362eeb2d288f05e333aaf75481 > > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2617658 > > Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> > > Reviewed-by: Jamie Madill <jmadill@chromium.org> > > Reviewed-by: Charlie Lao <cclao@google.com> > > TBR=syoussefi@chromium.org,jmadill@chromium.org,cclao@google.com > > Change-Id: Ia03988b9c17639513576e82e8f11cd4c7b52640b > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: angleproject:3606 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2634202 > Reviewed-by: Tim Van Patten <timvp@google.com> > Commit-Queue: Tim Van Patten <timvp@google.com> TBR=timvp@google.com,syoussefi@chromium.org,jmadill@chromium.org,cclao@google.com # Not skipping CQ checks because this is a reland. Bug: angleproject:3606 Change-Id: Ib5b5925528a5c8698390b81f71ee788f5b332a1f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2633708 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org>
parent beea4050
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
// Version number for shader translation API. // Version number for shader translation API.
// It is incremented every time the API changes. // It is incremented every time the API changes.
#define ANGLE_SH_VERSION 249 #define ANGLE_SH_VERSION 250
enum ShShaderSpec enum ShShaderSpec
{ {
...@@ -346,9 +346,13 @@ const ShCompileOptions SH_FORCE_SHADER_PRECISION_HIGHP_TO_MEDIUMP = UINT64_C(1) ...@@ -346,9 +346,13 @@ const ShCompileOptions SH_FORCE_SHADER_PRECISION_HIGHP_TO_MEDIUMP = UINT64_C(1)
// Allow compiler to use specialization constant to do pre-rotation and y flip. // Allow compiler to use specialization constant to do pre-rotation and y flip.
const ShCompileOptions SH_USE_SPECIALIZATION_CONSTANT = UINT64_C(1) << 58; const ShCompileOptions SH_USE_SPECIALIZATION_CONSTANT = UINT64_C(1) << 58;
// Ask compiler to generate transform feedback emulation support code. // Ask compiler to generate Vulkan transform feedback emulation support code.
const ShCompileOptions SH_ADD_VULKAN_XFB_EMULATION_SUPPORT_CODE = UINT64_C(1) << 59; const ShCompileOptions SH_ADD_VULKAN_XFB_EMULATION_SUPPORT_CODE = UINT64_C(1) << 59;
// Ask compiler to generate Vulkan transform feedback support code when using the
// VK_EXT_transform_feedback extension.
const ShCompileOptions SH_ADD_VULKAN_XFB_EXTENSION_SUPPORT_CODE = UINT64_C(1) << 60;
// Defines alternate strategies for implementing array index clamping. // Defines alternate strategies for implementing array index clamping.
enum ShArrayIndexClampingStrategy enum ShArrayIndexClampingStrategy
{ {
...@@ -871,12 +875,15 @@ extern const char kAtomicCountersBlockName[]; ...@@ -871,12 +875,15 @@ extern const char kAtomicCountersBlockName[];
// Line raster emulation varying // Line raster emulation varying
extern const char kLineRasterEmulationPosition[]; extern const char kLineRasterEmulationPosition[];
// Transform feedback emulation helper function // Transform feedback emulation support
extern const char kXfbEmulationGetOffsetsFunctionName[]; extern const char kXfbEmulationGetOffsetsFunctionName[];
extern const char kXfbEmulationBufferBlockName[]; extern const char kXfbEmulationBufferBlockName[];
extern const char kXfbEmulationBufferName[]; extern const char kXfbEmulationBufferName[];
extern const char kXfbEmulationBufferFieldName[]; extern const char kXfbEmulationBufferFieldName[];
// Transform feedback extension support
extern const char kXfbExtensionPositionOutName[];
} // namespace vk } // namespace vk
namespace mtl namespace mtl
......
...@@ -800,6 +800,8 @@ const char kXfbEmulationBufferBlockName[] = "ANGLEXfbBuffer"; ...@@ -800,6 +800,8 @@ const char kXfbEmulationBufferBlockName[] = "ANGLEXfbBuffer";
const char kXfbEmulationBufferName[] = "ANGLEXfb"; const char kXfbEmulationBufferName[] = "ANGLEXfb";
const char kXfbEmulationBufferFieldName[] = "xfbOut"; const char kXfbEmulationBufferFieldName[] = "xfbOut";
const char kXfbExtensionPositionOutName[] = "ANGLEXfbPosition";
} // namespace vk } // namespace vk
} // namespace sh } // namespace sh
...@@ -480,6 +480,48 @@ ANGLE_NO_DISCARD bool AddXfbEmulationSupport(TCompiler *compiler, ...@@ -480,6 +480,48 @@ ANGLE_NO_DISCARD bool AddXfbEmulationSupport(TCompiler *compiler,
return compiler->validateAST(root); return compiler->validateAST(root);
} }
ANGLE_NO_DISCARD bool AddXfbExtensionSupport(TCompiler *compiler,
TIntermBlock *root,
TSymbolTable *symbolTable,
const DriverUniform *driverUniforms)
{
// Generate the following output varying declaration used to capture transform feedback output
// from gl_Position, as it can't be captured directly due to changes that are applied to it for
// clip-space correction and pre-rotation.
//
// out vec4 ANGLEXfbPosition;
const TType *vec4Type = nullptr;
switch (compiler->getShaderType())
{
case GL_VERTEX_SHADER:
vec4Type = StaticType::Get<EbtFloat, EbpHigh, EvqVertexOut, 4, 1>();
break;
case GL_TESS_EVALUATION_SHADER_EXT:
vec4Type = StaticType::Get<EbtFloat, EbpHigh, EvqTessEvaluationOut, 4, 1>();
break;
case GL_GEOMETRY_SHADER_EXT:
vec4Type = StaticType::Get<EbtFloat, EbpHigh, EvqGeometryOut, 4, 1>();
break;
default:
UNREACHABLE();
}
TVariable *varyingVar =
new TVariable(symbolTable, ImmutableString(vk::kXfbExtensionPositionOutName), vec4Type,
SymbolType::AngleInternal);
TIntermDeclaration *varyingDecl = new TIntermDeclaration();
varyingDecl->appendDeclarator(new TIntermSymbol(varyingVar));
// Insert the varying declaration before the first function.
const size_t firstFunctionIndex = FindFirstFunctionDefinitionIndex(root);
root->insertChildNodes(firstFunctionIndex, {varyingDecl});
return compiler->validateAST(root);
}
ANGLE_NO_DISCARD bool InsertFragCoordCorrection(TCompiler *compiler, ANGLE_NO_DISCARD bool InsertFragCoordCorrection(TCompiler *compiler,
ShCompileOptions compileOptions, ShCompileOptions compileOptions,
TIntermBlock *root, TIntermBlock *root,
...@@ -881,8 +923,14 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root, ...@@ -881,8 +923,14 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
if (gl::ShaderTypeSupportsTransformFeedback(packedShaderType)) if (gl::ShaderTypeSupportsTransformFeedback(packedShaderType))
{ {
// Add a macro to declare transform feedback buffers. if (compileOptions & SH_ADD_VULKAN_XFB_EXTENSION_SUPPORT_CODE)
sink << "@@ XFB-DECL @@\n\n"; {
// Add support code for transform feedback extension.
if (!AddXfbExtensionSupport(this, root, &getSymbolTable(), driverUniforms))
{
return false;
}
}
// Append a macro for transform feedback substitution prior to modifying depth. // Append a macro for transform feedback substitution prior to modifying depth.
if (!AppendTransformFeedbackOutputToMain(this, root, &getSymbolTable())) if (!AppendTransformFeedbackOutputToMain(this, root, &getSymbolTable()))
......
...@@ -82,7 +82,11 @@ std::shared_ptr<WaitableCompileEvent> ShaderVk::compile(const gl::Context *conte ...@@ -82,7 +82,11 @@ std::shared_ptr<WaitableCompileEvent> ShaderVk::compile(const gl::Context *conte
compileOptions |= SH_ADD_PRE_ROTATION; compileOptions |= SH_ADD_PRE_ROTATION;
} }
if (contextVk->getFeatures().emulateTransformFeedback.enabled) if (contextVk->getFeatures().supportsTransformFeedbackExtension.enabled)
{
compileOptions |= SH_ADD_VULKAN_XFB_EXTENSION_SUPPORT_CODE;
}
else if (contextVk->getFeatures().emulateTransformFeedback.enabled)
{ {
compileOptions |= SH_ADD_VULKAN_XFB_EMULATION_SUPPORT_CODE; compileOptions |= SH_ADD_VULKAN_XFB_EMULATION_SUPPORT_CODE;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment