Commit ba0bd785 by Qin Jiajia Committed by Commit Bot

Fix the assert error and inbalence parens for SSBO

This PR strengthens below two cases: 1. Support calculate unsized array size for any type. Previously, it reported error when the type was a structure. 2. Correctly add the right paren for store function when any load/length functions are nested in it. Bug: angleproject:5734 Change-Id: I3428fa35f1481275e1d193094ceddb011f747cf1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2762655Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jiajia Qin <jiajia.qin@intel.com>
parent b717952e
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#ifndef COMPILER_TRANSLATOR_SHADERSTORAGEBLOCKOUTPUTHLSL_H_ #ifndef COMPILER_TRANSLATOR_SHADERSTORAGEBLOCKOUTPUTHLSL_H_
#define COMPILER_TRANSLATOR_SHADERSTORAGEBLOCKOUTPUTHLSL_H_ #define COMPILER_TRANSLATOR_SHADERSTORAGEBLOCKOUTPUTHLSL_H_
#include <stack>
#include "compiler/translator/ShaderStorageBlockFunctionHLSL.h" #include "compiler/translator/ShaderStorageBlockFunctionHLSL.h"
#include "compiler/translator/blocklayout.h" #include "compiler/translator/blocklayout.h"
#include "compiler/translator/tree_util/IntermTraverse.h" #include "compiler/translator/tree_util/IntermTraverse.h"
...@@ -75,10 +76,11 @@ class ShaderStorageBlockOutputHLSL : public TIntermTraverser ...@@ -75,10 +76,11 @@ class ShaderStorageBlockOutputHLSL : public TIntermTraverser
void writeEOpIndexDirectOrIndirectOutput(TInfoSinkBase &out, Visit visit, TIntermBinary *node); void writeEOpIndexDirectOrIndirectOutput(TInfoSinkBase &out, Visit visit, TIntermBinary *node);
// Common part in dot operations. // Common part in dot operations.
void writeDotOperatorOutput(TInfoSinkBase &out, const TField *field); void writeDotOperatorOutput(TInfoSinkBase &out, const TField *field);
void collectShaderStorageBlocks(TIntermTyped *node);
int mMatrixStride; int mMatrixStride;
bool mRowMajor; bool mRowMajor;
bool mLocationAsTheLastArgument; std::stack<SSBOMethod> mMethodTypeStack;
OutputHLSL *mOutputHLSL; OutputHLSL *mOutputHLSL;
ShaderStorageBlockFunctionHLSL *mSSBOFunctionHLSL; ShaderStorageBlockFunctionHLSL *mSSBOFunctionHLSL;
ResourcesHLSL *mResourcesHLSL; ResourcesHLSL *mResourcesHLSL;
......
...@@ -2640,6 +2640,37 @@ void main() ...@@ -2640,6 +2640,37 @@ void main()
EXPECT_EQ(100u, outputValue); EXPECT_EQ(100u, outputValue);
} }
// Test that the length of a struct buffer variable is supported.
TEST_P(ComputeShaderTest, ShaderStorageBlocksStructLength)
{
const char kCSSource[] = R"(#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
struct Particle
{
int len;
};
layout(binding = 0, std430) readonly buffer Buf1
{
Particle particlesRead[];
};
layout(binding = 1, std430) buffer Buf2
{
Particle particlesWrite[];
};
void main()
{
int index = int(gl_GlobalInvocationID.x);
particlesWrite[index].len = particlesRead.length();
})";
ANGLE_GL_COMPUTE_PROGRAM(program, kCSSource);
EXPECT_GL_NO_ERROR();
}
// Test that scalar buffer variables are supported. // Test that scalar buffer variables are supported.
TEST_P(ComputeShaderTest, ShaderStorageBlocksScalar) TEST_P(ComputeShaderTest, ShaderStorageBlocksScalar)
{ {
......
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