1*8975f5c5SAndroid Build Coastguard Worker // 2*8975f5c5SAndroid Build Coastguard Worker // Copyright 2020 The ANGLE Project Authors. All rights reserved. 3*8975f5c5SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be 4*8975f5c5SAndroid Build Coastguard Worker // found in the LICENSE file. 5*8975f5c5SAndroid Build Coastguard Worker // 6*8975f5c5SAndroid Build Coastguard Worker // ProgramExecutable.h: Collects the information and interfaces common to both Programs and 7*8975f5c5SAndroid Build Coastguard Worker // ProgramPipelines in order to execute/draw with either. 8*8975f5c5SAndroid Build Coastguard Worker 9*8975f5c5SAndroid Build Coastguard Worker #ifndef LIBANGLE_PROGRAMEXECUTABLE_H_ 10*8975f5c5SAndroid Build Coastguard Worker #define LIBANGLE_PROGRAMEXECUTABLE_H_ 11*8975f5c5SAndroid Build Coastguard Worker 12*8975f5c5SAndroid Build Coastguard Worker #include "common/BinaryStream.h" 13*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Caps.h" 14*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/InfoLog.h" 15*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/ProgramLinkedResources.h" 16*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Shader.h" 17*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Uniform.h" 18*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/VaryingPacking.h" 19*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/angletypes.h" 20*8975f5c5SAndroid Build Coastguard Worker 21*8975f5c5SAndroid Build Coastguard Worker namespace rx 22*8975f5c5SAndroid Build Coastguard Worker { 23*8975f5c5SAndroid Build Coastguard Worker class GLImplFactory; 24*8975f5c5SAndroid Build Coastguard Worker class LinkSubTask; 25*8975f5c5SAndroid Build Coastguard Worker class ProgramExecutableImpl; 26*8975f5c5SAndroid Build Coastguard Worker } // namespace rx 27*8975f5c5SAndroid Build Coastguard Worker 28*8975f5c5SAndroid Build Coastguard Worker namespace gl 29*8975f5c5SAndroid Build Coastguard Worker { 30*8975f5c5SAndroid Build Coastguard Worker 31*8975f5c5SAndroid Build Coastguard Worker // This small structure encapsulates binding sampler uniforms to active GL textures. 32*8975f5c5SAndroid Build Coastguard Worker ANGLE_ENABLE_STRUCT_PADDING_WARNINGS 33*8975f5c5SAndroid Build Coastguard Worker struct SamplerBinding 34*8975f5c5SAndroid Build Coastguard Worker { 35*8975f5c5SAndroid Build Coastguard Worker SamplerBinding() = default; SamplerBindingSamplerBinding36*8975f5c5SAndroid Build Coastguard Worker SamplerBinding(TextureType textureTypeIn, 37*8975f5c5SAndroid Build Coastguard Worker GLenum samplerTypeIn, 38*8975f5c5SAndroid Build Coastguard Worker SamplerFormat formatIn, 39*8975f5c5SAndroid Build Coastguard Worker uint16_t startIndex, 40*8975f5c5SAndroid Build Coastguard Worker uint16_t elementCount) 41*8975f5c5SAndroid Build Coastguard Worker : textureType(textureTypeIn), 42*8975f5c5SAndroid Build Coastguard Worker format(formatIn), 43*8975f5c5SAndroid Build Coastguard Worker textureUnitsStartIndex(startIndex), 44*8975f5c5SAndroid Build Coastguard Worker textureUnitsCount(elementCount) 45*8975f5c5SAndroid Build Coastguard Worker { 46*8975f5c5SAndroid Build Coastguard Worker SetBitField(samplerType, samplerTypeIn); 47*8975f5c5SAndroid Build Coastguard Worker } 48*8975f5c5SAndroid Build Coastguard Worker getTextureUnitSamplerBinding49*8975f5c5SAndroid Build Coastguard Worker GLuint getTextureUnit(const std::vector<GLuint> &boundTextureUnits, 50*8975f5c5SAndroid Build Coastguard Worker unsigned int arrayIndex) const 51*8975f5c5SAndroid Build Coastguard Worker { 52*8975f5c5SAndroid Build Coastguard Worker return boundTextureUnits[textureUnitsStartIndex + arrayIndex]; 53*8975f5c5SAndroid Build Coastguard Worker } 54*8975f5c5SAndroid Build Coastguard Worker 55*8975f5c5SAndroid Build Coastguard Worker // Necessary for retrieving active textures from the GL state. 56*8975f5c5SAndroid Build Coastguard Worker TextureType textureType; 57*8975f5c5SAndroid Build Coastguard Worker SamplerFormat format; 58*8975f5c5SAndroid Build Coastguard Worker uint16_t samplerType; 59*8975f5c5SAndroid Build Coastguard Worker // [textureUnitsStartIndex, textureUnitsStartIndex+textureUnitsCount) Points to the subset in 60*8975f5c5SAndroid Build Coastguard Worker // mSamplerBoundTextureUnits that stores the texture unit bound to this sampler. Cropped by the 61*8975f5c5SAndroid Build Coastguard Worker // amount of unused elements reported by the driver. 62*8975f5c5SAndroid Build Coastguard Worker uint16_t textureUnitsStartIndex; 63*8975f5c5SAndroid Build Coastguard Worker uint16_t textureUnitsCount; 64*8975f5c5SAndroid Build Coastguard Worker }; 65*8975f5c5SAndroid Build Coastguard Worker ANGLE_DISABLE_STRUCT_PADDING_WARNINGS 66*8975f5c5SAndroid Build Coastguard Worker 67*8975f5c5SAndroid Build Coastguard Worker struct ImageBinding 68*8975f5c5SAndroid Build Coastguard Worker { 69*8975f5c5SAndroid Build Coastguard Worker ImageBinding() = default; ImageBindingImageBinding70*8975f5c5SAndroid Build Coastguard Worker ImageBinding(size_t count, TextureType textureTypeIn) 71*8975f5c5SAndroid Build Coastguard Worker : textureType(textureTypeIn), boundImageUnits(count, 0) 72*8975f5c5SAndroid Build Coastguard Worker {} 73*8975f5c5SAndroid Build Coastguard Worker ImageBinding(GLuint imageUnit, size_t count, TextureType textureTypeIn); 74*8975f5c5SAndroid Build Coastguard Worker 75*8975f5c5SAndroid Build Coastguard Worker // Necessary for distinguishing between textures with images and texture buffers. 76*8975f5c5SAndroid Build Coastguard Worker TextureType textureType; 77*8975f5c5SAndroid Build Coastguard Worker 78*8975f5c5SAndroid Build Coastguard Worker // List of all textures bound. 79*8975f5c5SAndroid Build Coastguard Worker // Cropped by the amount of unused elements reported by the driver. 80*8975f5c5SAndroid Build Coastguard Worker std::vector<GLuint> boundImageUnits; 81*8975f5c5SAndroid Build Coastguard Worker }; 82*8975f5c5SAndroid Build Coastguard Worker 83*8975f5c5SAndroid Build Coastguard Worker ANGLE_ENABLE_STRUCT_PADDING_WARNINGS 84*8975f5c5SAndroid Build Coastguard Worker struct ProgramInput 85*8975f5c5SAndroid Build Coastguard Worker { 86*8975f5c5SAndroid Build Coastguard Worker ProgramInput() = default; 87*8975f5c5SAndroid Build Coastguard Worker ProgramInput(const sh::ShaderVariable &var); 88*8975f5c5SAndroid Build Coastguard Worker getTypeProgramInput89*8975f5c5SAndroid Build Coastguard Worker GLenum getType() const { return pod.type; } isBuiltInProgramInput90*8975f5c5SAndroid Build Coastguard Worker bool isBuiltIn() const { return pod.flagBits.isBuiltIn; } isArrayProgramInput91*8975f5c5SAndroid Build Coastguard Worker bool isArray() const { return pod.flagBits.isArray; } isActiveProgramInput92*8975f5c5SAndroid Build Coastguard Worker bool isActive() const { return pod.flagBits.active; } isPatchProgramInput93*8975f5c5SAndroid Build Coastguard Worker bool isPatch() const { return pod.flagBits.isPatch; } getLocationProgramInput94*8975f5c5SAndroid Build Coastguard Worker int getLocation() const { return pod.location; } getBasicTypeElementCountProgramInput95*8975f5c5SAndroid Build Coastguard Worker unsigned int getBasicTypeElementCount() const { return pod.basicTypeElementCount; } getArraySizeProductProgramInput96*8975f5c5SAndroid Build Coastguard Worker unsigned int getArraySizeProduct() const { return pod.arraySizeProduct; } getIdProgramInput97*8975f5c5SAndroid Build Coastguard Worker uint32_t getId() const { return pod.id; } getInterpolationProgramInput98*8975f5c5SAndroid Build Coastguard Worker sh::InterpolationType getInterpolation() const 99*8975f5c5SAndroid Build Coastguard Worker { 100*8975f5c5SAndroid Build Coastguard Worker return static_cast<sh::InterpolationType>(pod.interpolation); 101*8975f5c5SAndroid Build Coastguard Worker } 102*8975f5c5SAndroid Build Coastguard Worker setLocationProgramInput103*8975f5c5SAndroid Build Coastguard Worker void setLocation(int location) { pod.location = location; } resetEffectiveLocationProgramInput104*8975f5c5SAndroid Build Coastguard Worker void resetEffectiveLocation() 105*8975f5c5SAndroid Build Coastguard Worker { 106*8975f5c5SAndroid Build Coastguard Worker if (pod.flagBits.hasImplicitLocation) 107*8975f5c5SAndroid Build Coastguard Worker { 108*8975f5c5SAndroid Build Coastguard Worker pod.location = -1; 109*8975f5c5SAndroid Build Coastguard Worker } 110*8975f5c5SAndroid Build Coastguard Worker } 111*8975f5c5SAndroid Build Coastguard Worker 112*8975f5c5SAndroid Build Coastguard Worker std::string name; 113*8975f5c5SAndroid Build Coastguard Worker std::string mappedName; 114*8975f5c5SAndroid Build Coastguard Worker 115*8975f5c5SAndroid Build Coastguard Worker // The struct bellow must only contain data of basic type so that entire struct can memcpy-able. 116*8975f5c5SAndroid Build Coastguard Worker struct PODStruct 117*8975f5c5SAndroid Build Coastguard Worker { 118*8975f5c5SAndroid Build Coastguard Worker uint16_t type; // GLenum 119*8975f5c5SAndroid Build Coastguard Worker uint16_t arraySizeProduct; 120*8975f5c5SAndroid Build Coastguard Worker 121*8975f5c5SAndroid Build Coastguard Worker int location; 122*8975f5c5SAndroid Build Coastguard Worker 123*8975f5c5SAndroid Build Coastguard Worker uint8_t interpolation; // sh::InterpolationType 124*8975f5c5SAndroid Build Coastguard Worker union 125*8975f5c5SAndroid Build Coastguard Worker { 126*8975f5c5SAndroid Build Coastguard Worker struct 127*8975f5c5SAndroid Build Coastguard Worker { 128*8975f5c5SAndroid Build Coastguard Worker uint8_t active : 1; 129*8975f5c5SAndroid Build Coastguard Worker uint8_t isPatch : 1; 130*8975f5c5SAndroid Build Coastguard Worker uint8_t hasImplicitLocation : 1; 131*8975f5c5SAndroid Build Coastguard Worker uint8_t isArray : 1; 132*8975f5c5SAndroid Build Coastguard Worker uint8_t isBuiltIn : 1; 133*8975f5c5SAndroid Build Coastguard Worker uint8_t padding : 3; 134*8975f5c5SAndroid Build Coastguard Worker } flagBits; 135*8975f5c5SAndroid Build Coastguard Worker uint8_t flagBitsAsUByte; 136*8975f5c5SAndroid Build Coastguard Worker }; 137*8975f5c5SAndroid Build Coastguard Worker int16_t basicTypeElementCount; 138*8975f5c5SAndroid Build Coastguard Worker 139*8975f5c5SAndroid Build Coastguard Worker uint32_t id; 140*8975f5c5SAndroid Build Coastguard Worker } pod; 141*8975f5c5SAndroid Build Coastguard Worker }; 142*8975f5c5SAndroid Build Coastguard Worker ANGLE_DISABLE_STRUCT_PADDING_WARNINGS 143*8975f5c5SAndroid Build Coastguard Worker 144*8975f5c5SAndroid Build Coastguard Worker ANGLE_ENABLE_STRUCT_PADDING_WARNINGS 145*8975f5c5SAndroid Build Coastguard Worker struct ProgramOutput 146*8975f5c5SAndroid Build Coastguard Worker { 147*8975f5c5SAndroid Build Coastguard Worker ProgramOutput() = default; 148*8975f5c5SAndroid Build Coastguard Worker ProgramOutput(const sh::ShaderVariable &var); isBuiltInProgramOutput149*8975f5c5SAndroid Build Coastguard Worker bool isBuiltIn() const { return pod.isBuiltIn; } isArrayProgramOutput150*8975f5c5SAndroid Build Coastguard Worker bool isArray() const { return pod.isArray; } getLocationProgramOutput151*8975f5c5SAndroid Build Coastguard Worker int getLocation() const { return pod.location; } getOutermostArraySizeProgramOutput152*8975f5c5SAndroid Build Coastguard Worker unsigned int getOutermostArraySize() const { return pod.outermostArraySize; } resetEffectiveLocationProgramOutput153*8975f5c5SAndroid Build Coastguard Worker void resetEffectiveLocation() 154*8975f5c5SAndroid Build Coastguard Worker { 155*8975f5c5SAndroid Build Coastguard Worker if (pod.hasImplicitLocation) 156*8975f5c5SAndroid Build Coastguard Worker { 157*8975f5c5SAndroid Build Coastguard Worker pod.location = -1; 158*8975f5c5SAndroid Build Coastguard Worker } 159*8975f5c5SAndroid Build Coastguard Worker } 160*8975f5c5SAndroid Build Coastguard Worker 161*8975f5c5SAndroid Build Coastguard Worker std::string name; 162*8975f5c5SAndroid Build Coastguard Worker std::string mappedName; 163*8975f5c5SAndroid Build Coastguard Worker 164*8975f5c5SAndroid Build Coastguard Worker struct PODStruct 165*8975f5c5SAndroid Build Coastguard Worker { 166*8975f5c5SAndroid Build Coastguard Worker GLenum type; 167*8975f5c5SAndroid Build Coastguard Worker int location; 168*8975f5c5SAndroid Build Coastguard Worker int index; 169*8975f5c5SAndroid Build Coastguard Worker uint32_t id; 170*8975f5c5SAndroid Build Coastguard Worker 171*8975f5c5SAndroid Build Coastguard Worker uint16_t outermostArraySize; 172*8975f5c5SAndroid Build Coastguard Worker uint16_t basicTypeElementCount; 173*8975f5c5SAndroid Build Coastguard Worker 174*8975f5c5SAndroid Build Coastguard Worker uint32_t isPatch : 1; 175*8975f5c5SAndroid Build Coastguard Worker uint32_t yuv : 1; 176*8975f5c5SAndroid Build Coastguard Worker uint32_t isBuiltIn : 1; 177*8975f5c5SAndroid Build Coastguard Worker uint32_t isArray : 1; 178*8975f5c5SAndroid Build Coastguard Worker uint32_t hasImplicitLocation : 1; 179*8975f5c5SAndroid Build Coastguard Worker uint32_t hasShaderAssignedLocation : 1; 180*8975f5c5SAndroid Build Coastguard Worker uint32_t hasApiAssignedLocation : 1; 181*8975f5c5SAndroid Build Coastguard Worker uint32_t pad : 25; 182*8975f5c5SAndroid Build Coastguard Worker } pod; 183*8975f5c5SAndroid Build Coastguard Worker }; 184*8975f5c5SAndroid Build Coastguard Worker ANGLE_DISABLE_STRUCT_PADDING_WARNINGS 185*8975f5c5SAndroid Build Coastguard Worker 186*8975f5c5SAndroid Build Coastguard Worker // A varying with transform feedback enabled. If it's an array, either the whole array or one of its 187*8975f5c5SAndroid Build Coastguard Worker // elements specified by 'arrayIndex' can set to be enabled. 188*8975f5c5SAndroid Build Coastguard Worker struct TransformFeedbackVarying : public sh::ShaderVariable 189*8975f5c5SAndroid Build Coastguard Worker { 190*8975f5c5SAndroid Build Coastguard Worker TransformFeedbackVarying() = default; 191*8975f5c5SAndroid Build Coastguard Worker TransformFeedbackVaryingTransformFeedbackVarying192*8975f5c5SAndroid Build Coastguard Worker TransformFeedbackVarying(const sh::ShaderVariable &varyingIn, GLuint arrayIndexIn) 193*8975f5c5SAndroid Build Coastguard Worker : sh::ShaderVariable(varyingIn), arrayIndex(arrayIndexIn) 194*8975f5c5SAndroid Build Coastguard Worker { 195*8975f5c5SAndroid Build Coastguard Worker ASSERT(!isArrayOfArrays()); 196*8975f5c5SAndroid Build Coastguard Worker } 197*8975f5c5SAndroid Build Coastguard Worker TransformFeedbackVaryingTransformFeedbackVarying198*8975f5c5SAndroid Build Coastguard Worker TransformFeedbackVarying(const sh::ShaderVariable &field, const sh::ShaderVariable &parent) 199*8975f5c5SAndroid Build Coastguard Worker : arrayIndex(GL_INVALID_INDEX) 200*8975f5c5SAndroid Build Coastguard Worker { 201*8975f5c5SAndroid Build Coastguard Worker sh::ShaderVariable *thisVar = this; 202*8975f5c5SAndroid Build Coastguard Worker *thisVar = field; 203*8975f5c5SAndroid Build Coastguard Worker interpolation = parent.interpolation; 204*8975f5c5SAndroid Build Coastguard Worker isInvariant = parent.isInvariant; 205*8975f5c5SAndroid Build Coastguard Worker ASSERT(parent.isShaderIOBlock || !parent.name.empty()); 206*8975f5c5SAndroid Build Coastguard Worker if (!parent.name.empty()) 207*8975f5c5SAndroid Build Coastguard Worker { 208*8975f5c5SAndroid Build Coastguard Worker name = parent.name + "." + name; 209*8975f5c5SAndroid Build Coastguard Worker mappedName = parent.mappedName + "." + mappedName; 210*8975f5c5SAndroid Build Coastguard Worker } 211*8975f5c5SAndroid Build Coastguard Worker structOrBlockName = parent.structOrBlockName; 212*8975f5c5SAndroid Build Coastguard Worker mappedStructOrBlockName = parent.mappedStructOrBlockName; 213*8975f5c5SAndroid Build Coastguard Worker } 214*8975f5c5SAndroid Build Coastguard Worker nameWithArrayIndexTransformFeedbackVarying215*8975f5c5SAndroid Build Coastguard Worker std::string nameWithArrayIndex() const 216*8975f5c5SAndroid Build Coastguard Worker { 217*8975f5c5SAndroid Build Coastguard Worker std::stringstream fullNameStr; 218*8975f5c5SAndroid Build Coastguard Worker fullNameStr << name; 219*8975f5c5SAndroid Build Coastguard Worker if (arrayIndex != GL_INVALID_INDEX) 220*8975f5c5SAndroid Build Coastguard Worker { 221*8975f5c5SAndroid Build Coastguard Worker fullNameStr << "[" << arrayIndex << "]"; 222*8975f5c5SAndroid Build Coastguard Worker } 223*8975f5c5SAndroid Build Coastguard Worker return fullNameStr.str(); 224*8975f5c5SAndroid Build Coastguard Worker } sizeTransformFeedbackVarying225*8975f5c5SAndroid Build Coastguard Worker GLsizei size() const 226*8975f5c5SAndroid Build Coastguard Worker { 227*8975f5c5SAndroid Build Coastguard Worker return (isArray() && arrayIndex == GL_INVALID_INDEX ? getOutermostArraySize() : 1); 228*8975f5c5SAndroid Build Coastguard Worker } 229*8975f5c5SAndroid Build Coastguard Worker 230*8975f5c5SAndroid Build Coastguard Worker GLuint arrayIndex; 231*8975f5c5SAndroid Build Coastguard Worker }; 232*8975f5c5SAndroid Build Coastguard Worker 233*8975f5c5SAndroid Build Coastguard Worker class ProgramState; 234*8975f5c5SAndroid Build Coastguard Worker class ProgramPipelineState; 235*8975f5c5SAndroid Build Coastguard Worker 236*8975f5c5SAndroid Build Coastguard Worker class ProgramExecutable; 237*8975f5c5SAndroid Build Coastguard Worker using SharedProgramExecutable = std::shared_ptr<ProgramExecutable>; 238*8975f5c5SAndroid Build Coastguard Worker 239*8975f5c5SAndroid Build Coastguard Worker class ProgramExecutable final : public angle::Subject 240*8975f5c5SAndroid Build Coastguard Worker { 241*8975f5c5SAndroid Build Coastguard Worker public: 242*8975f5c5SAndroid Build Coastguard Worker ProgramExecutable(rx::GLImplFactory *factory, InfoLog *infoLog); 243*8975f5c5SAndroid Build Coastguard Worker ~ProgramExecutable() override; 244*8975f5c5SAndroid Build Coastguard Worker 245*8975f5c5SAndroid Build Coastguard Worker void destroy(const Context *context); 246*8975f5c5SAndroid Build Coastguard Worker getImplementation()247*8975f5c5SAndroid Build Coastguard Worker ANGLE_INLINE rx::ProgramExecutableImpl *getImplementation() const { return mImplementation; } 248*8975f5c5SAndroid Build Coastguard Worker 249*8975f5c5SAndroid Build Coastguard Worker void save(gl::BinaryOutputStream *stream) const; 250*8975f5c5SAndroid Build Coastguard Worker void load(gl::BinaryInputStream *stream); 251*8975f5c5SAndroid Build Coastguard Worker getInfoLog()252*8975f5c5SAndroid Build Coastguard Worker InfoLog &getInfoLog() const { return *mInfoLog; } 253*8975f5c5SAndroid Build Coastguard Worker std::string getInfoLogString() const; resetInfoLog()254*8975f5c5SAndroid Build Coastguard Worker void resetInfoLog() const { mInfoLog->reset(); } 255*8975f5c5SAndroid Build Coastguard Worker resetLinkedShaderStages()256*8975f5c5SAndroid Build Coastguard Worker void resetLinkedShaderStages() { mPod.linkedShaderStages.reset(); } getLinkedShaderStages()257*8975f5c5SAndroid Build Coastguard Worker const ShaderBitSet getLinkedShaderStages() const { return mPod.linkedShaderStages; } setLinkedShaderStages(ShaderType shaderType)258*8975f5c5SAndroid Build Coastguard Worker void setLinkedShaderStages(ShaderType shaderType) 259*8975f5c5SAndroid Build Coastguard Worker { 260*8975f5c5SAndroid Build Coastguard Worker mPod.linkedShaderStages.set(shaderType); 261*8975f5c5SAndroid Build Coastguard Worker updateCanDrawWith(); 262*8975f5c5SAndroid Build Coastguard Worker } hasLinkedShaderStage(ShaderType shaderType)263*8975f5c5SAndroid Build Coastguard Worker bool hasLinkedShaderStage(ShaderType shaderType) const 264*8975f5c5SAndroid Build Coastguard Worker { 265*8975f5c5SAndroid Build Coastguard Worker ASSERT(shaderType != ShaderType::InvalidEnum); 266*8975f5c5SAndroid Build Coastguard Worker return mPod.linkedShaderStages[shaderType]; 267*8975f5c5SAndroid Build Coastguard Worker } getLinkedShaderStageCount()268*8975f5c5SAndroid Build Coastguard Worker size_t getLinkedShaderStageCount() const { return mPod.linkedShaderStages.count(); } hasLinkedGraphicsShader()269*8975f5c5SAndroid Build Coastguard Worker bool hasLinkedGraphicsShader() const 270*8975f5c5SAndroid Build Coastguard Worker { 271*8975f5c5SAndroid Build Coastguard Worker return mPod.linkedShaderStages.any() && 272*8975f5c5SAndroid Build Coastguard Worker mPod.linkedShaderStages != gl::ShaderBitSet{gl::ShaderType::Compute}; 273*8975f5c5SAndroid Build Coastguard Worker } hasLinkedTessellationShader()274*8975f5c5SAndroid Build Coastguard Worker bool hasLinkedTessellationShader() const 275*8975f5c5SAndroid Build Coastguard Worker { 276*8975f5c5SAndroid Build Coastguard Worker return mPod.linkedShaderStages[ShaderType::TessEvaluation]; 277*8975f5c5SAndroid Build Coastguard Worker } 278*8975f5c5SAndroid Build Coastguard Worker ShaderType getFirstLinkedShaderStageType() const; 279*8975f5c5SAndroid Build Coastguard Worker ShaderType getLastLinkedShaderStageType() const; 280*8975f5c5SAndroid Build Coastguard Worker getLinkedTransformFeedbackStage()281*8975f5c5SAndroid Build Coastguard Worker ShaderType getLinkedTransformFeedbackStage() const 282*8975f5c5SAndroid Build Coastguard Worker { 283*8975f5c5SAndroid Build Coastguard Worker return GetLastPreFragmentStage(mPod.linkedShaderStages); 284*8975f5c5SAndroid Build Coastguard Worker } 285*8975f5c5SAndroid Build Coastguard Worker getActiveAttribLocationsMask()286*8975f5c5SAndroid Build Coastguard Worker const AttributesMask &getActiveAttribLocationsMask() const 287*8975f5c5SAndroid Build Coastguard Worker { 288*8975f5c5SAndroid Build Coastguard Worker return mPod.activeAttribLocationsMask; 289*8975f5c5SAndroid Build Coastguard Worker } isAttribLocationActive(size_t attribLocation)290*8975f5c5SAndroid Build Coastguard Worker bool isAttribLocationActive(size_t attribLocation) const 291*8975f5c5SAndroid Build Coastguard Worker { 292*8975f5c5SAndroid Build Coastguard Worker ASSERT(attribLocation < mPod.activeAttribLocationsMask.size()); 293*8975f5c5SAndroid Build Coastguard Worker return mPod.activeAttribLocationsMask[attribLocation]; 294*8975f5c5SAndroid Build Coastguard Worker } 295*8975f5c5SAndroid Build Coastguard Worker getNonBuiltinAttribLocationsMask()296*8975f5c5SAndroid Build Coastguard Worker AttributesMask getNonBuiltinAttribLocationsMask() const { return mPod.attributesMask; } getMaxActiveAttribLocation()297*8975f5c5SAndroid Build Coastguard Worker unsigned int getMaxActiveAttribLocation() const { return mPod.maxActiveAttribLocation; } getAttributesTypeMask()298*8975f5c5SAndroid Build Coastguard Worker ComponentTypeMask getAttributesTypeMask() const { return mPod.attributesTypeMask; } getAttributesMask()299*8975f5c5SAndroid Build Coastguard Worker AttributesMask getAttributesMask() const { return mPod.attributesMask; } 300*8975f5c5SAndroid Build Coastguard Worker getActiveSamplersMask()301*8975f5c5SAndroid Build Coastguard Worker const ActiveTextureMask &getActiveSamplersMask() const { return mActiveSamplersMask; } setActiveTextureMask(ActiveTextureMask mask)302*8975f5c5SAndroid Build Coastguard Worker void setActiveTextureMask(ActiveTextureMask mask) { mActiveSamplersMask = mask; } getSamplerFormatForTextureUnitIndex(size_t textureUnitIndex)303*8975f5c5SAndroid Build Coastguard Worker SamplerFormat getSamplerFormatForTextureUnitIndex(size_t textureUnitIndex) const 304*8975f5c5SAndroid Build Coastguard Worker { 305*8975f5c5SAndroid Build Coastguard Worker return mActiveSamplerFormats[textureUnitIndex]; 306*8975f5c5SAndroid Build Coastguard Worker } getSamplerShaderBitsForTextureUnitIndex(size_t textureUnitIndex)307*8975f5c5SAndroid Build Coastguard Worker const ShaderBitSet getSamplerShaderBitsForTextureUnitIndex(size_t textureUnitIndex) const 308*8975f5c5SAndroid Build Coastguard Worker { 309*8975f5c5SAndroid Build Coastguard Worker return mActiveSamplerShaderBits[textureUnitIndex]; 310*8975f5c5SAndroid Build Coastguard Worker } getActiveImagesMask()311*8975f5c5SAndroid Build Coastguard Worker const ActiveTextureMask &getActiveImagesMask() const { return mActiveImagesMask; } setActiveImagesMask(ActiveTextureMask mask)312*8975f5c5SAndroid Build Coastguard Worker void setActiveImagesMask(ActiveTextureMask mask) { mActiveImagesMask = mask; } getActiveImageShaderBits()313*8975f5c5SAndroid Build Coastguard Worker const ActiveTextureArray<ShaderBitSet> &getActiveImageShaderBits() const 314*8975f5c5SAndroid Build Coastguard Worker { 315*8975f5c5SAndroid Build Coastguard Worker return mActiveImageShaderBits; 316*8975f5c5SAndroid Build Coastguard Worker } 317*8975f5c5SAndroid Build Coastguard Worker getActiveYUVSamplers()318*8975f5c5SAndroid Build Coastguard Worker const ActiveTextureMask &getActiveYUVSamplers() const { return mActiveSamplerYUV; } 319*8975f5c5SAndroid Build Coastguard Worker getActiveSamplerTypes()320*8975f5c5SAndroid Build Coastguard Worker const ActiveTextureArray<TextureType> &getActiveSamplerTypes() const 321*8975f5c5SAndroid Build Coastguard Worker { 322*8975f5c5SAndroid Build Coastguard Worker return mActiveSamplerTypes; 323*8975f5c5SAndroid Build Coastguard Worker } 324*8975f5c5SAndroid Build Coastguard Worker 325*8975f5c5SAndroid Build Coastguard Worker void setActive(size_t textureUnit, 326*8975f5c5SAndroid Build Coastguard Worker const SamplerBinding &samplerBinding, 327*8975f5c5SAndroid Build Coastguard Worker const gl::LinkedUniform &samplerUniform); 328*8975f5c5SAndroid Build Coastguard Worker void setInactive(size_t textureUnit); 329*8975f5c5SAndroid Build Coastguard Worker void hasSamplerTypeConflict(size_t textureUnit); 330*8975f5c5SAndroid Build Coastguard Worker void hasSamplerFormatConflict(size_t textureUnit); 331*8975f5c5SAndroid Build Coastguard Worker 332*8975f5c5SAndroid Build Coastguard Worker void updateActiveSamplers(const ProgramExecutable &executable); 333*8975f5c5SAndroid Build Coastguard Worker hasDefaultUniforms()334*8975f5c5SAndroid Build Coastguard Worker bool hasDefaultUniforms() const { return !getDefaultUniformRange().empty(); } hasTextures()335*8975f5c5SAndroid Build Coastguard Worker bool hasTextures() const { return !getSamplerBindings().empty(); } hasUniformBuffers()336*8975f5c5SAndroid Build Coastguard Worker bool hasUniformBuffers() const { return !mUniformBlocks.empty(); } hasStorageBuffers()337*8975f5c5SAndroid Build Coastguard Worker bool hasStorageBuffers() const { return !mShaderStorageBlocks.empty(); } hasAtomicCounterBuffers()338*8975f5c5SAndroid Build Coastguard Worker bool hasAtomicCounterBuffers() const { return !mAtomicCounterBuffers.empty(); } hasImages()339*8975f5c5SAndroid Build Coastguard Worker bool hasImages() const { return !mImageBindings.empty(); } hasTransformFeedbackOutput()340*8975f5c5SAndroid Build Coastguard Worker bool hasTransformFeedbackOutput() const 341*8975f5c5SAndroid Build Coastguard Worker { 342*8975f5c5SAndroid Build Coastguard Worker return !getLinkedTransformFeedbackVaryings().empty(); 343*8975f5c5SAndroid Build Coastguard Worker } usesColorFramebufferFetch()344*8975f5c5SAndroid Build Coastguard Worker bool usesColorFramebufferFetch() const { return mPod.fragmentInoutIndices.any(); } usesDepthFramebufferFetch()345*8975f5c5SAndroid Build Coastguard Worker bool usesDepthFramebufferFetch() const { return mPod.hasDepthInputAttachment; } usesStencilFramebufferFetch()346*8975f5c5SAndroid Build Coastguard Worker bool usesStencilFramebufferFetch() const { return mPod.hasStencilInputAttachment; } 347*8975f5c5SAndroid Build Coastguard Worker 348*8975f5c5SAndroid Build Coastguard Worker // Count the number of uniform and storage buffer declarations, counting arrays as one. getTransformFeedbackBufferCount()349*8975f5c5SAndroid Build Coastguard Worker size_t getTransformFeedbackBufferCount() const { return mTransformFeedbackStrides.size(); } 350*8975f5c5SAndroid Build Coastguard Worker updateCanDrawWith()351*8975f5c5SAndroid Build Coastguard Worker void updateCanDrawWith() { mPod.canDrawWith = hasLinkedShaderStage(ShaderType::Vertex); } hasVertexShader()352*8975f5c5SAndroid Build Coastguard Worker bool hasVertexShader() const { return mPod.canDrawWith; } 353*8975f5c5SAndroid Build Coastguard Worker getProgramInputs()354*8975f5c5SAndroid Build Coastguard Worker const std::vector<ProgramInput> &getProgramInputs() const { return mProgramInputs; } getOutputVariables()355*8975f5c5SAndroid Build Coastguard Worker const std::vector<ProgramOutput> &getOutputVariables() const { return mOutputVariables; } getOutputLocations()356*8975f5c5SAndroid Build Coastguard Worker const std::vector<VariableLocation> &getOutputLocations() const { return mOutputLocations; } getSecondaryOutputLocations()357*8975f5c5SAndroid Build Coastguard Worker const std::vector<VariableLocation> &getSecondaryOutputLocations() const 358*8975f5c5SAndroid Build Coastguard Worker { 359*8975f5c5SAndroid Build Coastguard Worker return mSecondaryOutputLocations; 360*8975f5c5SAndroid Build Coastguard Worker } getUniforms()361*8975f5c5SAndroid Build Coastguard Worker const std::vector<LinkedUniform> &getUniforms() const { return mUniforms; } getUniformNames()362*8975f5c5SAndroid Build Coastguard Worker const std::vector<std::string> &getUniformNames() const { return mUniformNames; } getUniformMappedNames()363*8975f5c5SAndroid Build Coastguard Worker const std::vector<std::string> &getUniformMappedNames() const { return mUniformMappedNames; } getUniformBlocks()364*8975f5c5SAndroid Build Coastguard Worker const std::vector<InterfaceBlock> &getUniformBlocks() const { return mUniformBlocks; } getUniformLocations()365*8975f5c5SAndroid Build Coastguard Worker const std::vector<VariableLocation> &getUniformLocations() const { return mUniformLocations; } getSamplerBindings()366*8975f5c5SAndroid Build Coastguard Worker const std::vector<SamplerBinding> &getSamplerBindings() const { return mSamplerBindings; } getSamplerBoundTextureUnits()367*8975f5c5SAndroid Build Coastguard Worker const std::vector<GLuint> &getSamplerBoundTextureUnits() const 368*8975f5c5SAndroid Build Coastguard Worker { 369*8975f5c5SAndroid Build Coastguard Worker return mSamplerBoundTextureUnits; 370*8975f5c5SAndroid Build Coastguard Worker } getImageBindings()371*8975f5c5SAndroid Build Coastguard Worker const std::vector<ImageBinding> &getImageBindings() const { return mImageBindings; } getPixelLocalStorageFormats()372*8975f5c5SAndroid Build Coastguard Worker const std::vector<ShPixelLocalStorageFormat> &getPixelLocalStorageFormats() const 373*8975f5c5SAndroid Build Coastguard Worker { 374*8975f5c5SAndroid Build Coastguard Worker return mPixelLocalStorageFormats; 375*8975f5c5SAndroid Build Coastguard Worker } getImageBindings()376*8975f5c5SAndroid Build Coastguard Worker std::vector<ImageBinding> *getImageBindings() { return &mImageBindings; } getDefaultUniformRange()377*8975f5c5SAndroid Build Coastguard Worker const RangeUI &getDefaultUniformRange() const { return mPod.defaultUniformRange; } getSamplerUniformRange()378*8975f5c5SAndroid Build Coastguard Worker const RangeUI &getSamplerUniformRange() const { return mPod.samplerUniformRange; } getImageUniformRange()379*8975f5c5SAndroid Build Coastguard Worker const RangeUI &getImageUniformRange() const { return mPod.imageUniformRange; } getAtomicCounterUniformRange()380*8975f5c5SAndroid Build Coastguard Worker const RangeUI &getAtomicCounterUniformRange() const { return mPod.atomicCounterUniformRange; } getFragmentInoutIndices()381*8975f5c5SAndroid Build Coastguard Worker DrawBufferMask getFragmentInoutIndices() const { return mPod.fragmentInoutIndices; } hasClipDistance()382*8975f5c5SAndroid Build Coastguard Worker bool hasClipDistance() const { return mPod.hasClipDistance; } hasDiscard()383*8975f5c5SAndroid Build Coastguard Worker bool hasDiscard() const { return mPod.hasDiscard; } hasDepthInputAttachment()384*8975f5c5SAndroid Build Coastguard Worker bool hasDepthInputAttachment() const { return mPod.hasDepthInputAttachment; } hasStencilInputAttachment()385*8975f5c5SAndroid Build Coastguard Worker bool hasStencilInputAttachment() const { return mPod.hasStencilInputAttachment; } enablesPerSampleShading()386*8975f5c5SAndroid Build Coastguard Worker bool enablesPerSampleShading() const { return mPod.enablesPerSampleShading; } getAdvancedBlendEquations()387*8975f5c5SAndroid Build Coastguard Worker BlendEquationBitSet getAdvancedBlendEquations() const { return mPod.advancedBlendEquations; } getLinkedTransformFeedbackVaryings()388*8975f5c5SAndroid Build Coastguard Worker const std::vector<TransformFeedbackVarying> &getLinkedTransformFeedbackVaryings() const 389*8975f5c5SAndroid Build Coastguard Worker { 390*8975f5c5SAndroid Build Coastguard Worker return mLinkedTransformFeedbackVaryings; 391*8975f5c5SAndroid Build Coastguard Worker } getTransformFeedbackBufferMode()392*8975f5c5SAndroid Build Coastguard Worker GLint getTransformFeedbackBufferMode() const { return mPod.transformFeedbackBufferMode; } getComputeShaderLocalSize()393*8975f5c5SAndroid Build Coastguard Worker const sh::WorkGroupSize &getComputeShaderLocalSize() const 394*8975f5c5SAndroid Build Coastguard Worker { 395*8975f5c5SAndroid Build Coastguard Worker return mPod.computeShaderLocalSize; 396*8975f5c5SAndroid Build Coastguard Worker } 397*8975f5c5SAndroid Build Coastguard Worker void remapUniformBlockBinding(UniformBlockIndex uniformBlockIndex, GLuint uniformBlockBinding); getUniformBlockBinding(size_t uniformBlockIndex)398*8975f5c5SAndroid Build Coastguard Worker GLuint getUniformBlockBinding(size_t uniformBlockIndex) const 399*8975f5c5SAndroid Build Coastguard Worker { 400*8975f5c5SAndroid Build Coastguard Worker ASSERT(uniformBlockIndex < mUniformBlocks.size()); 401*8975f5c5SAndroid Build Coastguard Worker 402*8975f5c5SAndroid Build Coastguard Worker // Unlike SSBOs and atomic counter buffers, GLES allows UBOs bindings to be remapped. Note 403*8975f5c5SAndroid Build Coastguard Worker // that desktop GL allows SSBO bindings to also be remapped, but that's not allowed in GLES. 404*8975f5c5SAndroid Build Coastguard Worker // 405*8975f5c5SAndroid Build Coastguard Worker // It's therefore important to never directly reference block.pod.inShaderBinding unless the 406*8975f5c5SAndroid Build Coastguard Worker // specific shader-specified binding is required. 407*8975f5c5SAndroid Build Coastguard Worker return mUniformBlockIndexToBufferBinding[uniformBlockIndex]; 408*8975f5c5SAndroid Build Coastguard Worker } getShaderStorageBlockBinding(size_t blockIndex)409*8975f5c5SAndroid Build Coastguard Worker GLuint getShaderStorageBlockBinding(size_t blockIndex) const 410*8975f5c5SAndroid Build Coastguard Worker { 411*8975f5c5SAndroid Build Coastguard Worker ASSERT(blockIndex < mShaderStorageBlocks.size()); 412*8975f5c5SAndroid Build Coastguard Worker // The buffer binding for SSBOs is the one specified in the shader 413*8975f5c5SAndroid Build Coastguard Worker return mShaderStorageBlocks[blockIndex].pod.inShaderBinding; 414*8975f5c5SAndroid Build Coastguard Worker } getAtomicCounterBufferBinding(size_t blockIndex)415*8975f5c5SAndroid Build Coastguard Worker GLuint getAtomicCounterBufferBinding(size_t blockIndex) const 416*8975f5c5SAndroid Build Coastguard Worker { 417*8975f5c5SAndroid Build Coastguard Worker ASSERT(blockIndex < mAtomicCounterBuffers.size()); 418*8975f5c5SAndroid Build Coastguard Worker // The buffer binding for atomic counter buffers is the one specified in the shader 419*8975f5c5SAndroid Build Coastguard Worker return mAtomicCounterBuffers[blockIndex].pod.inShaderBinding; 420*8975f5c5SAndroid Build Coastguard Worker } getUniformBlockByIndex(size_t index)421*8975f5c5SAndroid Build Coastguard Worker const InterfaceBlock &getUniformBlockByIndex(size_t index) const 422*8975f5c5SAndroid Build Coastguard Worker { 423*8975f5c5SAndroid Build Coastguard Worker ASSERT(index < mUniformBlocks.size()); 424*8975f5c5SAndroid Build Coastguard Worker return mUniformBlocks[index]; 425*8975f5c5SAndroid Build Coastguard Worker } getShaderStorageBlockByIndex(size_t index)426*8975f5c5SAndroid Build Coastguard Worker const InterfaceBlock &getShaderStorageBlockByIndex(size_t index) const 427*8975f5c5SAndroid Build Coastguard Worker { 428*8975f5c5SAndroid Build Coastguard Worker ASSERT(index < mShaderStorageBlocks.size()); 429*8975f5c5SAndroid Build Coastguard Worker return mShaderStorageBlocks[index]; 430*8975f5c5SAndroid Build Coastguard Worker } getBufferVariableByIndex(size_t index)431*8975f5c5SAndroid Build Coastguard Worker const BufferVariable &getBufferVariableByIndex(size_t index) const 432*8975f5c5SAndroid Build Coastguard Worker { 433*8975f5c5SAndroid Build Coastguard Worker ASSERT(index < mBufferVariables.size()); 434*8975f5c5SAndroid Build Coastguard Worker return mBufferVariables[index]; 435*8975f5c5SAndroid Build Coastguard Worker } getTransformFeedbackStrides()436*8975f5c5SAndroid Build Coastguard Worker const std::vector<GLsizei> &getTransformFeedbackStrides() const 437*8975f5c5SAndroid Build Coastguard Worker { 438*8975f5c5SAndroid Build Coastguard Worker return mTransformFeedbackStrides; 439*8975f5c5SAndroid Build Coastguard Worker } getAtomicCounterBuffers()440*8975f5c5SAndroid Build Coastguard Worker const std::vector<AtomicCounterBuffer> &getAtomicCounterBuffers() const 441*8975f5c5SAndroid Build Coastguard Worker { 442*8975f5c5SAndroid Build Coastguard Worker return mAtomicCounterBuffers; 443*8975f5c5SAndroid Build Coastguard Worker } getShaderStorageBlocks()444*8975f5c5SAndroid Build Coastguard Worker const std::vector<InterfaceBlock> &getShaderStorageBlocks() const 445*8975f5c5SAndroid Build Coastguard Worker { 446*8975f5c5SAndroid Build Coastguard Worker return mShaderStorageBlocks; 447*8975f5c5SAndroid Build Coastguard Worker } getBufferVariables()448*8975f5c5SAndroid Build Coastguard Worker const std::vector<BufferVariable> &getBufferVariables() const { return mBufferVariables; } getUniformByIndex(size_t index)449*8975f5c5SAndroid Build Coastguard Worker const LinkedUniform &getUniformByIndex(size_t index) const 450*8975f5c5SAndroid Build Coastguard Worker { 451*8975f5c5SAndroid Build Coastguard Worker ASSERT(index < static_cast<size_t>(mUniforms.size())); 452*8975f5c5SAndroid Build Coastguard Worker return mUniforms[index]; 453*8975f5c5SAndroid Build Coastguard Worker } getUniformNameByIndex(size_t index)454*8975f5c5SAndroid Build Coastguard Worker const std::string &getUniformNameByIndex(size_t index) const 455*8975f5c5SAndroid Build Coastguard Worker { 456*8975f5c5SAndroid Build Coastguard Worker ASSERT(index < static_cast<size_t>(mUniforms.size())); 457*8975f5c5SAndroid Build Coastguard Worker return mUniformNames[index]; 458*8975f5c5SAndroid Build Coastguard Worker } 459*8975f5c5SAndroid Build Coastguard Worker getUniformIndexFromImageIndex(size_t imageIndex)460*8975f5c5SAndroid Build Coastguard Worker GLuint getUniformIndexFromImageIndex(size_t imageIndex) const 461*8975f5c5SAndroid Build Coastguard Worker { 462*8975f5c5SAndroid Build Coastguard Worker ASSERT(imageIndex < mPod.imageUniformRange.length()); 463*8975f5c5SAndroid Build Coastguard Worker return static_cast<GLuint>(imageIndex) + mPod.imageUniformRange.low(); 464*8975f5c5SAndroid Build Coastguard Worker } 465*8975f5c5SAndroid Build Coastguard Worker getUniformIndexFromSamplerIndex(size_t samplerIndex)466*8975f5c5SAndroid Build Coastguard Worker GLuint getUniformIndexFromSamplerIndex(size_t samplerIndex) const 467*8975f5c5SAndroid Build Coastguard Worker { 468*8975f5c5SAndroid Build Coastguard Worker ASSERT(samplerIndex < mPod.samplerUniformRange.length()); 469*8975f5c5SAndroid Build Coastguard Worker return static_cast<GLuint>(samplerIndex) + mPod.samplerUniformRange.low(); 470*8975f5c5SAndroid Build Coastguard Worker } 471*8975f5c5SAndroid Build Coastguard Worker 472*8975f5c5SAndroid Build Coastguard Worker void saveLinkedStateInfo(const ProgramState &state); getLinkedOutputVaryings(ShaderType shaderType)473*8975f5c5SAndroid Build Coastguard Worker const std::vector<sh::ShaderVariable> &getLinkedOutputVaryings(ShaderType shaderType) const 474*8975f5c5SAndroid Build Coastguard Worker { 475*8975f5c5SAndroid Build Coastguard Worker return mLinkedOutputVaryings[shaderType]; 476*8975f5c5SAndroid Build Coastguard Worker } getLinkedInputVaryings(ShaderType shaderType)477*8975f5c5SAndroid Build Coastguard Worker const std::vector<sh::ShaderVariable> &getLinkedInputVaryings(ShaderType shaderType) const 478*8975f5c5SAndroid Build Coastguard Worker { 479*8975f5c5SAndroid Build Coastguard Worker return mLinkedInputVaryings[shaderType]; 480*8975f5c5SAndroid Build Coastguard Worker } 481*8975f5c5SAndroid Build Coastguard Worker getLinkedUniforms(ShaderType shaderType)482*8975f5c5SAndroid Build Coastguard Worker const std::vector<sh::ShaderVariable> &getLinkedUniforms(ShaderType shaderType) const 483*8975f5c5SAndroid Build Coastguard Worker { 484*8975f5c5SAndroid Build Coastguard Worker return mLinkedUniforms[shaderType]; 485*8975f5c5SAndroid Build Coastguard Worker } 486*8975f5c5SAndroid Build Coastguard Worker getLinkedUniformBlocks(ShaderType shaderType)487*8975f5c5SAndroid Build Coastguard Worker const std::vector<sh::InterfaceBlock> &getLinkedUniformBlocks(ShaderType shaderType) const 488*8975f5c5SAndroid Build Coastguard Worker { 489*8975f5c5SAndroid Build Coastguard Worker return mLinkedUniformBlocks[shaderType]; 490*8975f5c5SAndroid Build Coastguard Worker } 491*8975f5c5SAndroid Build Coastguard Worker getLinkedShaderVersion(ShaderType shaderType)492*8975f5c5SAndroid Build Coastguard Worker int getLinkedShaderVersion(ShaderType shaderType) const 493*8975f5c5SAndroid Build Coastguard Worker { 494*8975f5c5SAndroid Build Coastguard Worker return mPod.linkedShaderVersions[shaderType]; 495*8975f5c5SAndroid Build Coastguard Worker } 496*8975f5c5SAndroid Build Coastguard Worker isYUVOutput()497*8975f5c5SAndroid Build Coastguard Worker bool isYUVOutput() const { return mPod.hasYUVOutput; } 498*8975f5c5SAndroid Build Coastguard Worker getGeometryShaderInputPrimitiveType()499*8975f5c5SAndroid Build Coastguard Worker PrimitiveMode getGeometryShaderInputPrimitiveType() const 500*8975f5c5SAndroid Build Coastguard Worker { 501*8975f5c5SAndroid Build Coastguard Worker return mPod.geometryShaderInputPrimitiveType; 502*8975f5c5SAndroid Build Coastguard Worker } 503*8975f5c5SAndroid Build Coastguard Worker getGeometryShaderOutputPrimitiveType()504*8975f5c5SAndroid Build Coastguard Worker PrimitiveMode getGeometryShaderOutputPrimitiveType() const 505*8975f5c5SAndroid Build Coastguard Worker { 506*8975f5c5SAndroid Build Coastguard Worker return mPod.geometryShaderOutputPrimitiveType; 507*8975f5c5SAndroid Build Coastguard Worker } 508*8975f5c5SAndroid Build Coastguard Worker getGeometryShaderInvocations()509*8975f5c5SAndroid Build Coastguard Worker int getGeometryShaderInvocations() const { return mPod.geometryShaderInvocations; } 510*8975f5c5SAndroid Build Coastguard Worker getGeometryShaderMaxVertices()511*8975f5c5SAndroid Build Coastguard Worker int getGeometryShaderMaxVertices() const { return mPod.geometryShaderMaxVertices; } 512*8975f5c5SAndroid Build Coastguard Worker getTessControlShaderVertices()513*8975f5c5SAndroid Build Coastguard Worker GLint getTessControlShaderVertices() const { return mPod.tessControlShaderVertices; } getTessGenMode()514*8975f5c5SAndroid Build Coastguard Worker GLenum getTessGenMode() const { return mPod.tessGenMode; } getTessGenPointMode()515*8975f5c5SAndroid Build Coastguard Worker GLenum getTessGenPointMode() const { return mPod.tessGenPointMode; } getTessGenSpacing()516*8975f5c5SAndroid Build Coastguard Worker GLenum getTessGenSpacing() const { return mPod.tessGenSpacing; } getTessGenVertexOrder()517*8975f5c5SAndroid Build Coastguard Worker GLenum getTessGenVertexOrder() const { return mPod.tessGenVertexOrder; } 518*8975f5c5SAndroid Build Coastguard Worker getNumViews()519*8975f5c5SAndroid Build Coastguard Worker int getNumViews() const { return mPod.numViews; } usesMultiview()520*8975f5c5SAndroid Build Coastguard Worker bool usesMultiview() const { return mPod.numViews != -1; } 521*8975f5c5SAndroid Build Coastguard Worker getSpecConstUsageBits()522*8975f5c5SAndroid Build Coastguard Worker rx::SpecConstUsageBits getSpecConstUsageBits() const { return mPod.specConstUsageBits; } 523*8975f5c5SAndroid Build Coastguard Worker getDrawIDLocation()524*8975f5c5SAndroid Build Coastguard Worker int getDrawIDLocation() const { return mPod.drawIDLocation; } getBaseVertexLocation()525*8975f5c5SAndroid Build Coastguard Worker int getBaseVertexLocation() const { return mPod.baseVertexLocation; } getBaseInstanceLocation()526*8975f5c5SAndroid Build Coastguard Worker int getBaseInstanceLocation() const { return mPod.baseInstanceLocation; } 527*8975f5c5SAndroid Build Coastguard Worker hasDrawIDUniform()528*8975f5c5SAndroid Build Coastguard Worker bool hasDrawIDUniform() const { return getDrawIDLocation() >= 0; } hasBaseVertexUniform()529*8975f5c5SAndroid Build Coastguard Worker bool hasBaseVertexUniform() const { return getBaseVertexLocation() >= 0; } hasBaseInstanceUniform()530*8975f5c5SAndroid Build Coastguard Worker bool hasBaseInstanceUniform() const { return getBaseInstanceLocation() >= 0; } 531*8975f5c5SAndroid Build Coastguard Worker resetCachedValidateSamplersResult()532*8975f5c5SAndroid Build Coastguard Worker void resetCachedValidateSamplersResult() { mCachedValidateSamplersResult.reset(); } validateSamplers(const Caps & caps)533*8975f5c5SAndroid Build Coastguard Worker bool validateSamplers(const Caps &caps) const 534*8975f5c5SAndroid Build Coastguard Worker { 535*8975f5c5SAndroid Build Coastguard Worker // Use the cache if: 536*8975f5c5SAndroid Build Coastguard Worker // - we aren't using an info log (which gives the full error). 537*8975f5c5SAndroid Build Coastguard Worker // - The sample mapping hasn't changed and we've already validated. 538*8975f5c5SAndroid Build Coastguard Worker if (mCachedValidateSamplersResult.valid()) 539*8975f5c5SAndroid Build Coastguard Worker { 540*8975f5c5SAndroid Build Coastguard Worker return mCachedValidateSamplersResult.value(); 541*8975f5c5SAndroid Build Coastguard Worker } 542*8975f5c5SAndroid Build Coastguard Worker 543*8975f5c5SAndroid Build Coastguard Worker return validateSamplersImpl(caps); 544*8975f5c5SAndroid Build Coastguard Worker } 545*8975f5c5SAndroid Build Coastguard Worker getFragmentOutputsTypeMask()546*8975f5c5SAndroid Build Coastguard Worker ComponentTypeMask getFragmentOutputsTypeMask() const { return mPod.drawBufferTypeMask; } getActiveOutputVariablesMask()547*8975f5c5SAndroid Build Coastguard Worker DrawBufferMask getActiveOutputVariablesMask() const { return mPod.activeOutputVariablesMask; } getActiveSecondaryOutputVariablesMask()548*8975f5c5SAndroid Build Coastguard Worker DrawBufferMask getActiveSecondaryOutputVariablesMask() const 549*8975f5c5SAndroid Build Coastguard Worker { 550*8975f5c5SAndroid Build Coastguard Worker return mPod.activeSecondaryOutputVariablesMask; 551*8975f5c5SAndroid Build Coastguard Worker } 552*8975f5c5SAndroid Build Coastguard Worker 553*8975f5c5SAndroid Build Coastguard Worker GLuint getInputResourceIndex(const GLchar *name) const; 554*8975f5c5SAndroid Build Coastguard Worker GLuint getOutputResourceIndex(const GLchar *name) const; 555*8975f5c5SAndroid Build Coastguard Worker void getInputResourceName(GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name) const; 556*8975f5c5SAndroid Build Coastguard Worker void getOutputResourceName(GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name) const; 557*8975f5c5SAndroid Build Coastguard Worker void getUniformResourceName(GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name) const; 558*8975f5c5SAndroid Build Coastguard Worker void getBufferVariableResourceName(GLuint index, 559*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize, 560*8975f5c5SAndroid Build Coastguard Worker GLsizei *length, 561*8975f5c5SAndroid Build Coastguard Worker GLchar *name) const; getInputResource(size_t index)562*8975f5c5SAndroid Build Coastguard Worker const ProgramInput &getInputResource(size_t index) const 563*8975f5c5SAndroid Build Coastguard Worker { 564*8975f5c5SAndroid Build Coastguard Worker ASSERT(index < mProgramInputs.size()); 565*8975f5c5SAndroid Build Coastguard Worker return mProgramInputs[index]; 566*8975f5c5SAndroid Build Coastguard Worker } 567*8975f5c5SAndroid Build Coastguard Worker GLuint getInputResourceMaxNameSize() const; 568*8975f5c5SAndroid Build Coastguard Worker GLuint getOutputResourceMaxNameSize() const; 569*8975f5c5SAndroid Build Coastguard Worker GLuint getInputResourceLocation(const GLchar *name) const; 570*8975f5c5SAndroid Build Coastguard Worker GLuint getOutputResourceLocation(const GLchar *name) const; 571*8975f5c5SAndroid Build Coastguard Worker const std::string getInputResourceName(GLuint index) const; 572*8975f5c5SAndroid Build Coastguard Worker const std::string getOutputResourceName(GLuint index) const; getOutputResource(size_t index)573*8975f5c5SAndroid Build Coastguard Worker const gl::ProgramOutput &getOutputResource(size_t index) const 574*8975f5c5SAndroid Build Coastguard Worker { 575*8975f5c5SAndroid Build Coastguard Worker ASSERT(index < mOutputVariables.size()); 576*8975f5c5SAndroid Build Coastguard Worker return mOutputVariables[index]; 577*8975f5c5SAndroid Build Coastguard Worker } 578*8975f5c5SAndroid Build Coastguard Worker 579*8975f5c5SAndroid Build Coastguard Worker GLint getFragDataLocation(const std::string &name) const; 580*8975f5c5SAndroid Build Coastguard Worker 581*8975f5c5SAndroid Build Coastguard Worker // EXT_blend_func_extended 582*8975f5c5SAndroid Build Coastguard Worker GLint getFragDataIndex(const std::string &name) const; 583*8975f5c5SAndroid Build Coastguard Worker 584*8975f5c5SAndroid Build Coastguard Worker GLsizei getTransformFeedbackVaryingMaxLength() const; 585*8975f5c5SAndroid Build Coastguard Worker GLuint getTransformFeedbackVaryingResourceIndex(const GLchar *name) const; 586*8975f5c5SAndroid Build Coastguard Worker const TransformFeedbackVarying &getTransformFeedbackVaryingResource(GLuint index) const; 587*8975f5c5SAndroid Build Coastguard Worker void getTransformFeedbackVarying(GLuint index, 588*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize, 589*8975f5c5SAndroid Build Coastguard Worker GLsizei *length, 590*8975f5c5SAndroid Build Coastguard Worker GLsizei *size, 591*8975f5c5SAndroid Build Coastguard Worker GLenum *type, 592*8975f5c5SAndroid Build Coastguard Worker GLchar *name) const; 593*8975f5c5SAndroid Build Coastguard Worker 594*8975f5c5SAndroid Build Coastguard Worker void getActiveAttribute(GLuint index, 595*8975f5c5SAndroid Build Coastguard Worker GLsizei bufsize, 596*8975f5c5SAndroid Build Coastguard Worker GLsizei *length, 597*8975f5c5SAndroid Build Coastguard Worker GLint *size, 598*8975f5c5SAndroid Build Coastguard Worker GLenum *type, 599*8975f5c5SAndroid Build Coastguard Worker GLchar *name) const; 600*8975f5c5SAndroid Build Coastguard Worker GLint getActiveAttributeMaxLength() const; 601*8975f5c5SAndroid Build Coastguard Worker GLuint getAttributeLocation(const std::string &name) const; 602*8975f5c5SAndroid Build Coastguard Worker 603*8975f5c5SAndroid Build Coastguard Worker void getActiveUniform(GLuint index, 604*8975f5c5SAndroid Build Coastguard Worker GLsizei bufsize, 605*8975f5c5SAndroid Build Coastguard Worker GLsizei *length, 606*8975f5c5SAndroid Build Coastguard Worker GLint *size, 607*8975f5c5SAndroid Build Coastguard Worker GLenum *type, 608*8975f5c5SAndroid Build Coastguard Worker GLchar *name) const; 609*8975f5c5SAndroid Build Coastguard Worker GLint getActiveUniformMaxLength() const; 610*8975f5c5SAndroid Build Coastguard Worker bool isValidUniformLocation(UniformLocation location) const; 611*8975f5c5SAndroid Build Coastguard Worker const LinkedUniform &getUniformByLocation(UniformLocation location) const; 612*8975f5c5SAndroid Build Coastguard Worker const VariableLocation &getUniformLocation(UniformLocation location) const; 613*8975f5c5SAndroid Build Coastguard Worker UniformLocation getUniformLocation(const std::string &name) const; 614*8975f5c5SAndroid Build Coastguard Worker GLuint getUniformIndex(const std::string &name) const; 615*8975f5c5SAndroid Build Coastguard Worker 616*8975f5c5SAndroid Build Coastguard Worker void getActiveUniformBlockName(const Context *context, 617*8975f5c5SAndroid Build Coastguard Worker const UniformBlockIndex blockIndex, 618*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize, 619*8975f5c5SAndroid Build Coastguard Worker GLsizei *length, 620*8975f5c5SAndroid Build Coastguard Worker GLchar *blockName) const; 621*8975f5c5SAndroid Build Coastguard Worker void getActiveShaderStorageBlockName(const GLuint blockIndex, 622*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize, 623*8975f5c5SAndroid Build Coastguard Worker GLsizei *length, 624*8975f5c5SAndroid Build Coastguard Worker GLchar *blockName) const; 625*8975f5c5SAndroid Build Coastguard Worker 626*8975f5c5SAndroid Build Coastguard Worker GLint getActiveUniformBlockMaxNameLength() const; 627*8975f5c5SAndroid Build Coastguard Worker GLint getActiveShaderStorageBlockMaxNameLength() const; 628*8975f5c5SAndroid Build Coastguard Worker 629*8975f5c5SAndroid Build Coastguard Worker GLuint getUniformBlockIndex(const std::string &name) const; 630*8975f5c5SAndroid Build Coastguard Worker GLuint getShaderStorageBlockIndex(const std::string &name) const; 631*8975f5c5SAndroid Build Coastguard Worker 632*8975f5c5SAndroid Build Coastguard Worker GLuint getUniformIndexFromName(const std::string &name) const; 633*8975f5c5SAndroid Build Coastguard Worker GLuint getUniformIndexFromLocation(UniformLocation location) const; 634*8975f5c5SAndroid Build Coastguard Worker Optional<GLuint> getSamplerIndex(UniformLocation location) const; 635*8975f5c5SAndroid Build Coastguard Worker bool isSamplerUniformIndex(GLuint index) const; 636*8975f5c5SAndroid Build Coastguard Worker GLuint getSamplerIndexFromUniformIndex(GLuint uniformIndex) const; 637*8975f5c5SAndroid Build Coastguard Worker bool isImageUniformIndex(GLuint index) const; 638*8975f5c5SAndroid Build Coastguard Worker GLuint getImageIndexFromUniformIndex(GLuint uniformIndex) const; 639*8975f5c5SAndroid Build Coastguard Worker GLuint getBufferVariableIndexFromName(const std::string &name) const; 640*8975f5c5SAndroid Build Coastguard Worker 641*8975f5c5SAndroid Build Coastguard Worker bool linkUniforms(const Caps &caps, 642*8975f5c5SAndroid Build Coastguard Worker const ShaderMap<std::vector<sh::ShaderVariable>> &shaderUniforms, 643*8975f5c5SAndroid Build Coastguard Worker const ProgramAliasedBindings &uniformLocationBindings, 644*8975f5c5SAndroid Build Coastguard Worker GLuint *combinedImageUniformsCount, 645*8975f5c5SAndroid Build Coastguard Worker std::vector<UnusedUniform> *unusedUniforms); 646*8975f5c5SAndroid Build Coastguard Worker 647*8975f5c5SAndroid Build Coastguard Worker void copyInputsFromProgram(const ProgramExecutable &executable); 648*8975f5c5SAndroid Build Coastguard Worker void copyUniformBuffersFromProgram(const ProgramExecutable &executable, 649*8975f5c5SAndroid Build Coastguard Worker ShaderType shaderType, 650*8975f5c5SAndroid Build Coastguard Worker ProgramUniformBlockArray<GLuint> *ppoUniformBlockMap); 651*8975f5c5SAndroid Build Coastguard Worker void copyStorageBuffersFromProgram(const ProgramExecutable &executable, ShaderType shaderType); 652*8975f5c5SAndroid Build Coastguard Worker void clearSamplerBindings(); 653*8975f5c5SAndroid Build Coastguard Worker void copySamplerBindingsFromProgram(const ProgramExecutable &executable); 654*8975f5c5SAndroid Build Coastguard Worker void copyImageBindingsFromProgram(const ProgramExecutable &executable); 655*8975f5c5SAndroid Build Coastguard Worker void copyOutputsFromProgram(const ProgramExecutable &executable); 656*8975f5c5SAndroid Build Coastguard Worker void copyUniformsFromProgramMap(const ShaderMap<SharedProgramExecutable> &executables); 657*8975f5c5SAndroid Build Coastguard Worker 658*8975f5c5SAndroid Build Coastguard Worker void setUniform1fv(UniformLocation location, GLsizei count, const GLfloat *v); 659*8975f5c5SAndroid Build Coastguard Worker void setUniform2fv(UniformLocation location, GLsizei count, const GLfloat *v); 660*8975f5c5SAndroid Build Coastguard Worker void setUniform3fv(UniformLocation location, GLsizei count, const GLfloat *v); 661*8975f5c5SAndroid Build Coastguard Worker void setUniform4fv(UniformLocation location, GLsizei count, const GLfloat *v); 662*8975f5c5SAndroid Build Coastguard Worker void setUniform1iv(Context *context, UniformLocation location, GLsizei count, const GLint *v); 663*8975f5c5SAndroid Build Coastguard Worker void setUniform2iv(UniformLocation location, GLsizei count, const GLint *v); 664*8975f5c5SAndroid Build Coastguard Worker void setUniform3iv(UniformLocation location, GLsizei count, const GLint *v); 665*8975f5c5SAndroid Build Coastguard Worker void setUniform4iv(UniformLocation location, GLsizei count, const GLint *v); 666*8975f5c5SAndroid Build Coastguard Worker void setUniform1uiv(UniformLocation location, GLsizei count, const GLuint *v); 667*8975f5c5SAndroid Build Coastguard Worker void setUniform2uiv(UniformLocation location, GLsizei count, const GLuint *v); 668*8975f5c5SAndroid Build Coastguard Worker void setUniform3uiv(UniformLocation location, GLsizei count, const GLuint *v); 669*8975f5c5SAndroid Build Coastguard Worker void setUniform4uiv(UniformLocation location, GLsizei count, const GLuint *v); 670*8975f5c5SAndroid Build Coastguard Worker void setUniformMatrix2fv(UniformLocation location, 671*8975f5c5SAndroid Build Coastguard Worker GLsizei count, 672*8975f5c5SAndroid Build Coastguard Worker GLboolean transpose, 673*8975f5c5SAndroid Build Coastguard Worker const GLfloat *value); 674*8975f5c5SAndroid Build Coastguard Worker void setUniformMatrix3fv(UniformLocation location, 675*8975f5c5SAndroid Build Coastguard Worker GLsizei count, 676*8975f5c5SAndroid Build Coastguard Worker GLboolean transpose, 677*8975f5c5SAndroid Build Coastguard Worker const GLfloat *value); 678*8975f5c5SAndroid Build Coastguard Worker void setUniformMatrix4fv(UniformLocation location, 679*8975f5c5SAndroid Build Coastguard Worker GLsizei count, 680*8975f5c5SAndroid Build Coastguard Worker GLboolean transpose, 681*8975f5c5SAndroid Build Coastguard Worker const GLfloat *value); 682*8975f5c5SAndroid Build Coastguard Worker void setUniformMatrix2x3fv(UniformLocation location, 683*8975f5c5SAndroid Build Coastguard Worker GLsizei count, 684*8975f5c5SAndroid Build Coastguard Worker GLboolean transpose, 685*8975f5c5SAndroid Build Coastguard Worker const GLfloat *value); 686*8975f5c5SAndroid Build Coastguard Worker void setUniformMatrix3x2fv(UniformLocation location, 687*8975f5c5SAndroid Build Coastguard Worker GLsizei count, 688*8975f5c5SAndroid Build Coastguard Worker GLboolean transpose, 689*8975f5c5SAndroid Build Coastguard Worker const GLfloat *value); 690*8975f5c5SAndroid Build Coastguard Worker void setUniformMatrix2x4fv(UniformLocation location, 691*8975f5c5SAndroid Build Coastguard Worker GLsizei count, 692*8975f5c5SAndroid Build Coastguard Worker GLboolean transpose, 693*8975f5c5SAndroid Build Coastguard Worker const GLfloat *value); 694*8975f5c5SAndroid Build Coastguard Worker void setUniformMatrix4x2fv(UniformLocation location, 695*8975f5c5SAndroid Build Coastguard Worker GLsizei count, 696*8975f5c5SAndroid Build Coastguard Worker GLboolean transpose, 697*8975f5c5SAndroid Build Coastguard Worker const GLfloat *value); 698*8975f5c5SAndroid Build Coastguard Worker void setUniformMatrix3x4fv(UniformLocation location, 699*8975f5c5SAndroid Build Coastguard Worker GLsizei count, 700*8975f5c5SAndroid Build Coastguard Worker GLboolean transpose, 701*8975f5c5SAndroid Build Coastguard Worker const GLfloat *value); 702*8975f5c5SAndroid Build Coastguard Worker void setUniformMatrix4x3fv(UniformLocation location, 703*8975f5c5SAndroid Build Coastguard Worker GLsizei count, 704*8975f5c5SAndroid Build Coastguard Worker GLboolean transpose, 705*8975f5c5SAndroid Build Coastguard Worker const GLfloat *value); 706*8975f5c5SAndroid Build Coastguard Worker 707*8975f5c5SAndroid Build Coastguard Worker void getUniformfv(const Context *context, UniformLocation location, GLfloat *params) const; 708*8975f5c5SAndroid Build Coastguard Worker void getUniformiv(const Context *context, UniformLocation location, GLint *params) const; 709*8975f5c5SAndroid Build Coastguard Worker void getUniformuiv(const Context *context, UniformLocation location, GLuint *params) const; 710*8975f5c5SAndroid Build Coastguard Worker 711*8975f5c5SAndroid Build Coastguard Worker void setDrawIDUniform(GLint drawid); 712*8975f5c5SAndroid Build Coastguard Worker void setBaseVertexUniform(GLint baseVertex); 713*8975f5c5SAndroid Build Coastguard Worker void setBaseInstanceUniform(GLuint baseInstance); 714*8975f5c5SAndroid Build Coastguard Worker getUniformBufferBlocksMappedToBinding(size_t uniformBufferIndex)715*8975f5c5SAndroid Build Coastguard Worker ProgramUniformBlockMask getUniformBufferBlocksMappedToBinding(size_t uniformBufferIndex) 716*8975f5c5SAndroid Build Coastguard Worker { 717*8975f5c5SAndroid Build Coastguard Worker return mUniformBufferBindingToUniformBlocks[uniformBufferIndex]; 718*8975f5c5SAndroid Build Coastguard Worker } 719*8975f5c5SAndroid Build Coastguard Worker getUniformBlockIndexToBufferBindingForCapture()720*8975f5c5SAndroid Build Coastguard Worker const ProgramUniformBlockArray<GLuint> &getUniformBlockIndexToBufferBindingForCapture() const 721*8975f5c5SAndroid Build Coastguard Worker { 722*8975f5c5SAndroid Build Coastguard Worker return mUniformBlockIndexToBufferBinding; 723*8975f5c5SAndroid Build Coastguard Worker } 724*8975f5c5SAndroid Build Coastguard Worker getPPOProgramExecutables()725*8975f5c5SAndroid Build Coastguard Worker const ShaderMap<SharedProgramExecutable> &getPPOProgramExecutables() const 726*8975f5c5SAndroid Build Coastguard Worker { 727*8975f5c5SAndroid Build Coastguard Worker return mPPOProgramExecutables; 728*8975f5c5SAndroid Build Coastguard Worker } 729*8975f5c5SAndroid Build Coastguard Worker IsPPO()730*8975f5c5SAndroid Build Coastguard Worker bool IsPPO() const { return mIsPPO; } 731*8975f5c5SAndroid Build Coastguard Worker 732*8975f5c5SAndroid Build Coastguard Worker // Post-link task helpers getPostLinkSubTasks()733*8975f5c5SAndroid Build Coastguard Worker const std::vector<std::shared_ptr<rx::LinkSubTask>> &getPostLinkSubTasks() const 734*8975f5c5SAndroid Build Coastguard Worker { 735*8975f5c5SAndroid Build Coastguard Worker return mPostLinkSubTasks; 736*8975f5c5SAndroid Build Coastguard Worker } 737*8975f5c5SAndroid Build Coastguard Worker getPostLinkSubTaskWaitableEvents()738*8975f5c5SAndroid Build Coastguard Worker const std::vector<std::shared_ptr<angle::WaitableEvent>> &getPostLinkSubTaskWaitableEvents() 739*8975f5c5SAndroid Build Coastguard Worker const 740*8975f5c5SAndroid Build Coastguard Worker { 741*8975f5c5SAndroid Build Coastguard Worker return mPostLinkSubTaskWaitableEvents; 742*8975f5c5SAndroid Build Coastguard Worker } 743*8975f5c5SAndroid Build Coastguard Worker onPostLinkTasksComplete()744*8975f5c5SAndroid Build Coastguard Worker void onPostLinkTasksComplete() const 745*8975f5c5SAndroid Build Coastguard Worker { 746*8975f5c5SAndroid Build Coastguard Worker mPostLinkSubTasks.clear(); 747*8975f5c5SAndroid Build Coastguard Worker mPostLinkSubTaskWaitableEvents.clear(); 748*8975f5c5SAndroid Build Coastguard Worker } 749*8975f5c5SAndroid Build Coastguard Worker 750*8975f5c5SAndroid Build Coastguard Worker void waitForPostLinkTasks(const Context *context); 751*8975f5c5SAndroid Build Coastguard Worker 752*8975f5c5SAndroid Build Coastguard Worker private: 753*8975f5c5SAndroid Build Coastguard Worker friend class Program; 754*8975f5c5SAndroid Build Coastguard Worker friend class ProgramPipeline; 755*8975f5c5SAndroid Build Coastguard Worker friend class ProgramState; 756*8975f5c5SAndroid Build Coastguard Worker friend class ProgramPipelineState; 757*8975f5c5SAndroid Build Coastguard Worker 758*8975f5c5SAndroid Build Coastguard Worker void reset(); 759*8975f5c5SAndroid Build Coastguard Worker 760*8975f5c5SAndroid Build Coastguard Worker void updateActiveImages(const ProgramExecutable &executable); 761*8975f5c5SAndroid Build Coastguard Worker 762*8975f5c5SAndroid Build Coastguard Worker bool linkMergedVaryings(const Caps &caps, 763*8975f5c5SAndroid Build Coastguard Worker const Limitations &limitations, 764*8975f5c5SAndroid Build Coastguard Worker const Version &clientVersion, 765*8975f5c5SAndroid Build Coastguard Worker bool webglCompatibility, 766*8975f5c5SAndroid Build Coastguard Worker const ProgramMergedVaryings &mergedVaryings, 767*8975f5c5SAndroid Build Coastguard Worker const LinkingVariables &linkingVariables, 768*8975f5c5SAndroid Build Coastguard Worker ProgramVaryingPacking *varyingPacking); 769*8975f5c5SAndroid Build Coastguard Worker 770*8975f5c5SAndroid Build Coastguard Worker bool linkValidateTransformFeedback(const Caps &caps, 771*8975f5c5SAndroid Build Coastguard Worker const Version &clientVersion, 772*8975f5c5SAndroid Build Coastguard Worker const ProgramMergedVaryings &varyings, 773*8975f5c5SAndroid Build Coastguard Worker ShaderType stage); 774*8975f5c5SAndroid Build Coastguard Worker 775*8975f5c5SAndroid Build Coastguard Worker void gatherTransformFeedbackVaryings(const ProgramMergedVaryings &varyings, ShaderType stage); 776*8975f5c5SAndroid Build Coastguard Worker 777*8975f5c5SAndroid Build Coastguard Worker void updateTransformFeedbackStrides(); 778*8975f5c5SAndroid Build Coastguard Worker 779*8975f5c5SAndroid Build Coastguard Worker bool validateSamplersImpl(const Caps &caps) const; 780*8975f5c5SAndroid Build Coastguard Worker 781*8975f5c5SAndroid Build Coastguard Worker bool linkValidateOutputVariables(const Caps &caps, 782*8975f5c5SAndroid Build Coastguard Worker const Version &version, 783*8975f5c5SAndroid Build Coastguard Worker GLuint combinedImageUniformsCount, 784*8975f5c5SAndroid Build Coastguard Worker GLuint combinedShaderStorageBlocksCount, 785*8975f5c5SAndroid Build Coastguard Worker int fragmentShaderVersion, 786*8975f5c5SAndroid Build Coastguard Worker const ProgramAliasedBindings &fragmentOutputLocations, 787*8975f5c5SAndroid Build Coastguard Worker const ProgramAliasedBindings &fragmentOutputIndices); 788*8975f5c5SAndroid Build Coastguard Worker 789*8975f5c5SAndroid Build Coastguard Worker bool gatherOutputTypes(); 790*8975f5c5SAndroid Build Coastguard Worker 791*8975f5c5SAndroid Build Coastguard Worker void linkSamplerAndImageBindings(GLuint *combinedImageUniformsCount); 792*8975f5c5SAndroid Build Coastguard Worker bool linkAtomicCounterBuffers(const Caps &caps); 793*8975f5c5SAndroid Build Coastguard Worker 794*8975f5c5SAndroid Build Coastguard Worker void getResourceName(const std::string name, 795*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize, 796*8975f5c5SAndroid Build Coastguard Worker GLsizei *length, 797*8975f5c5SAndroid Build Coastguard Worker GLchar *dest) const; 798*8975f5c5SAndroid Build Coastguard Worker bool shouldIgnoreUniform(UniformLocation location) const; 799*8975f5c5SAndroid Build Coastguard Worker GLuint getSamplerUniformBinding(const VariableLocation &uniformLocation) const; 800*8975f5c5SAndroid Build Coastguard Worker GLuint getImageUniformBinding(const VariableLocation &uniformLocation) const; 801*8975f5c5SAndroid Build Coastguard Worker 802*8975f5c5SAndroid Build Coastguard Worker void initInterfaceBlockBindings(); 803*8975f5c5SAndroid Build Coastguard Worker void setUniformValuesFromBindingQualifiers(); 804*8975f5c5SAndroid Build Coastguard Worker 805*8975f5c5SAndroid Build Coastguard Worker // Both these function update the cached uniform values and return a modified "count" 806*8975f5c5SAndroid Build Coastguard Worker // so that the uniform update doesn't overflow the uniform. 807*8975f5c5SAndroid Build Coastguard Worker template <typename T> 808*8975f5c5SAndroid Build Coastguard Worker GLsizei clampUniformCount(const VariableLocation &locationInfo, 809*8975f5c5SAndroid Build Coastguard Worker GLsizei count, 810*8975f5c5SAndroid Build Coastguard Worker int vectorSize, 811*8975f5c5SAndroid Build Coastguard Worker const T *v); 812*8975f5c5SAndroid Build Coastguard Worker template <size_t cols, size_t rows, typename T> 813*8975f5c5SAndroid Build Coastguard Worker GLsizei clampMatrixUniformCount(UniformLocation location, 814*8975f5c5SAndroid Build Coastguard Worker GLsizei count, 815*8975f5c5SAndroid Build Coastguard Worker GLboolean transpose, 816*8975f5c5SAndroid Build Coastguard Worker const T *v); 817*8975f5c5SAndroid Build Coastguard Worker 818*8975f5c5SAndroid Build Coastguard Worker void updateSamplerUniform(Context *context, 819*8975f5c5SAndroid Build Coastguard Worker const VariableLocation &locationInfo, 820*8975f5c5SAndroid Build Coastguard Worker GLsizei clampedCount, 821*8975f5c5SAndroid Build Coastguard Worker const GLint *v); 822*8975f5c5SAndroid Build Coastguard Worker 823*8975f5c5SAndroid Build Coastguard Worker // Scans the sampler bindings for type conflicts with sampler 'textureUnitIndex'. 824*8975f5c5SAndroid Build Coastguard Worker void setSamplerUniformTextureTypeAndFormat(size_t textureUnitIndex); 825*8975f5c5SAndroid Build Coastguard Worker 826*8975f5c5SAndroid Build Coastguard Worker template <typename DestT> 827*8975f5c5SAndroid Build Coastguard Worker void getUniformInternal(const Context *context, 828*8975f5c5SAndroid Build Coastguard Worker DestT *dataOut, 829*8975f5c5SAndroid Build Coastguard Worker UniformLocation location, 830*8975f5c5SAndroid Build Coastguard Worker GLenum nativeType, 831*8975f5c5SAndroid Build Coastguard Worker int components) const; 832*8975f5c5SAndroid Build Coastguard Worker 833*8975f5c5SAndroid Build Coastguard Worker template <typename UniformT, 834*8975f5c5SAndroid Build Coastguard Worker GLint UniformSize, 835*8975f5c5SAndroid Build Coastguard Worker void (rx::ProgramExecutableImpl::*SetUniformFunc)(GLint, GLsizei, const UniformT *)> 836*8975f5c5SAndroid Build Coastguard Worker void setUniformGeneric(UniformLocation location, GLsizei count, const UniformT *v); 837*8975f5c5SAndroid Build Coastguard Worker 838*8975f5c5SAndroid Build Coastguard Worker template <typename UniformT, 839*8975f5c5SAndroid Build Coastguard Worker GLint MatrixC, 840*8975f5c5SAndroid Build Coastguard Worker GLint MatrixR, 841*8975f5c5SAndroid Build Coastguard Worker void (rx::ProgramExecutableImpl::* 842*8975f5c5SAndroid Build Coastguard Worker SetUniformMatrixFunc)(GLint, GLsizei, GLboolean, const UniformT *)> 843*8975f5c5SAndroid Build Coastguard Worker void setUniformMatrixGeneric(UniformLocation location, 844*8975f5c5SAndroid Build Coastguard Worker GLsizei count, 845*8975f5c5SAndroid Build Coastguard Worker GLboolean transpose, 846*8975f5c5SAndroid Build Coastguard Worker const UniformT *v); 847*8975f5c5SAndroid Build Coastguard Worker 848*8975f5c5SAndroid Build Coastguard Worker rx::ProgramExecutableImpl *mImplementation; 849*8975f5c5SAndroid Build Coastguard Worker 850*8975f5c5SAndroid Build Coastguard Worker // A reference to the owning object's (Program or ProgramPipeline) info log. It's kept here for 851*8975f5c5SAndroid Build Coastguard Worker // convenience as numerous functions reference it. 852*8975f5c5SAndroid Build Coastguard Worker InfoLog *mInfoLog; 853*8975f5c5SAndroid Build Coastguard Worker 854*8975f5c5SAndroid Build Coastguard Worker ANGLE_ENABLE_STRUCT_PADDING_WARNINGS 855*8975f5c5SAndroid Build Coastguard Worker struct PODStruct 856*8975f5c5SAndroid Build Coastguard Worker { 857*8975f5c5SAndroid Build Coastguard Worker // 8 bytes each 858*8975f5c5SAndroid Build Coastguard Worker angle::BitSet<MAX_VERTEX_ATTRIBS> activeAttribLocationsMask; 859*8975f5c5SAndroid Build Coastguard Worker ComponentTypeMask attributesTypeMask; 860*8975f5c5SAndroid Build Coastguard Worker // attributesMask is identical to mActiveAttribLocationsMask with built-in attributes 861*8975f5c5SAndroid Build Coastguard Worker // removed. 862*8975f5c5SAndroid Build Coastguard Worker AttributesMask attributesMask; 863*8975f5c5SAndroid Build Coastguard Worker ComponentTypeMask drawBufferTypeMask; 864*8975f5c5SAndroid Build Coastguard Worker 865*8975f5c5SAndroid Build Coastguard Worker // 4 bytes each 866*8975f5c5SAndroid Build Coastguard Worker uint32_t maxActiveAttribLocation; 867*8975f5c5SAndroid Build Coastguard Worker // KHR_blend_equation_advanced supported equation list 868*8975f5c5SAndroid Build Coastguard Worker BlendEquationBitSet advancedBlendEquations; 869*8975f5c5SAndroid Build Coastguard Worker 870*8975f5c5SAndroid Build Coastguard Worker // 1 byte each 871*8975f5c5SAndroid Build Coastguard Worker ShaderBitSet linkedShaderStages; 872*8975f5c5SAndroid Build Coastguard Worker DrawBufferMask activeOutputVariablesMask; 873*8975f5c5SAndroid Build Coastguard Worker DrawBufferMask activeSecondaryOutputVariablesMask; 874*8975f5c5SAndroid Build Coastguard Worker uint8_t hasClipDistance : 1; 875*8975f5c5SAndroid Build Coastguard Worker uint8_t hasDiscard : 1; 876*8975f5c5SAndroid Build Coastguard Worker uint8_t hasYUVOutput : 1; 877*8975f5c5SAndroid Build Coastguard Worker uint8_t hasDepthInputAttachment : 1; 878*8975f5c5SAndroid Build Coastguard Worker uint8_t hasStencilInputAttachment : 1; 879*8975f5c5SAndroid Build Coastguard Worker uint8_t enablesPerSampleShading : 1; 880*8975f5c5SAndroid Build Coastguard Worker uint8_t canDrawWith : 1; 881*8975f5c5SAndroid Build Coastguard Worker uint8_t isSeparable : 1; 882*8975f5c5SAndroid Build Coastguard Worker 883*8975f5c5SAndroid Build Coastguard Worker // 12 bytes 884*8975f5c5SAndroid Build Coastguard Worker sh::WorkGroupSize computeShaderLocalSize; 885*8975f5c5SAndroid Build Coastguard Worker 886*8975f5c5SAndroid Build Coastguard Worker // 8 bytes each 887*8975f5c5SAndroid Build Coastguard Worker RangeUI defaultUniformRange; 888*8975f5c5SAndroid Build Coastguard Worker RangeUI samplerUniformRange; 889*8975f5c5SAndroid Build Coastguard Worker RangeUI imageUniformRange; 890*8975f5c5SAndroid Build Coastguard Worker RangeUI atomicCounterUniformRange; 891*8975f5c5SAndroid Build Coastguard Worker 892*8975f5c5SAndroid Build Coastguard Worker // 1 byte. Bitset of which input attachments have been declared 893*8975f5c5SAndroid Build Coastguard Worker DrawBufferMask fragmentInoutIndices; 894*8975f5c5SAndroid Build Coastguard Worker 895*8975f5c5SAndroid Build Coastguard Worker // GL_EXT_geometry_shader. 896*8975f5c5SAndroid Build Coastguard Worker uint8_t pad0; 897*8975f5c5SAndroid Build Coastguard Worker PrimitiveMode geometryShaderInputPrimitiveType; 898*8975f5c5SAndroid Build Coastguard Worker PrimitiveMode geometryShaderOutputPrimitiveType; 899*8975f5c5SAndroid Build Coastguard Worker int32_t geometryShaderInvocations; 900*8975f5c5SAndroid Build Coastguard Worker int32_t geometryShaderMaxVertices; 901*8975f5c5SAndroid Build Coastguard Worker GLenum transformFeedbackBufferMode; 902*8975f5c5SAndroid Build Coastguard Worker 903*8975f5c5SAndroid Build Coastguard Worker // 4 bytes each. GL_OVR_multiview / GL_OVR_multiview2 904*8975f5c5SAndroid Build Coastguard Worker int32_t numViews; 905*8975f5c5SAndroid Build Coastguard Worker // GL_ANGLE_multi_draw 906*8975f5c5SAndroid Build Coastguard Worker int32_t drawIDLocation; 907*8975f5c5SAndroid Build Coastguard Worker 908*8975f5c5SAndroid Build Coastguard Worker // GL_ANGLE_base_vertex_base_instance_shader_builtin 909*8975f5c5SAndroid Build Coastguard Worker int32_t baseVertexLocation; 910*8975f5c5SAndroid Build Coastguard Worker int32_t baseInstanceLocation; 911*8975f5c5SAndroid Build Coastguard Worker 912*8975f5c5SAndroid Build Coastguard Worker // GL_EXT_tessellation_shader 913*8975f5c5SAndroid Build Coastguard Worker int32_t tessControlShaderVertices; 914*8975f5c5SAndroid Build Coastguard Worker GLenum tessGenMode; 915*8975f5c5SAndroid Build Coastguard Worker GLenum tessGenSpacing; 916*8975f5c5SAndroid Build Coastguard Worker GLenum tessGenVertexOrder; 917*8975f5c5SAndroid Build Coastguard Worker GLenum tessGenPointMode; 918*8975f5c5SAndroid Build Coastguard Worker 919*8975f5c5SAndroid Build Coastguard Worker // 4 bytes 920*8975f5c5SAndroid Build Coastguard Worker rx::SpecConstUsageBits specConstUsageBits; 921*8975f5c5SAndroid Build Coastguard Worker 922*8975f5c5SAndroid Build Coastguard Worker // 24 bytes 923*8975f5c5SAndroid Build Coastguard Worker ShaderMap<int> linkedShaderVersions; 924*8975f5c5SAndroid Build Coastguard Worker } mPod; 925*8975f5c5SAndroid Build Coastguard Worker ANGLE_DISABLE_STRUCT_PADDING_WARNINGS 926*8975f5c5SAndroid Build Coastguard Worker 927*8975f5c5SAndroid Build Coastguard Worker // Cached mask of active samplers and sampler types. 928*8975f5c5SAndroid Build Coastguard Worker ActiveTextureMask mActiveSamplersMask; 929*8975f5c5SAndroid Build Coastguard Worker ActiveTextureArray<uint32_t> mActiveSamplerRefCounts; 930*8975f5c5SAndroid Build Coastguard Worker ActiveTextureArray<TextureType> mActiveSamplerTypes; 931*8975f5c5SAndroid Build Coastguard Worker ActiveTextureMask mActiveSamplerYUV; 932*8975f5c5SAndroid Build Coastguard Worker ActiveTextureArray<SamplerFormat> mActiveSamplerFormats; 933*8975f5c5SAndroid Build Coastguard Worker ActiveTextureArray<ShaderBitSet> mActiveSamplerShaderBits; 934*8975f5c5SAndroid Build Coastguard Worker 935*8975f5c5SAndroid Build Coastguard Worker // Cached mask of active images. 936*8975f5c5SAndroid Build Coastguard Worker ActiveTextureMask mActiveImagesMask; 937*8975f5c5SAndroid Build Coastguard Worker ActiveTextureArray<ShaderBitSet> mActiveImageShaderBits; 938*8975f5c5SAndroid Build Coastguard Worker 939*8975f5c5SAndroid Build Coastguard Worker // Names and mapped names of output variables that are arrays include [0] in the end, similarly 940*8975f5c5SAndroid Build Coastguard Worker // to uniforms. 941*8975f5c5SAndroid Build Coastguard Worker std::vector<ProgramOutput> mOutputVariables; 942*8975f5c5SAndroid Build Coastguard Worker std::vector<VariableLocation> mOutputLocations; 943*8975f5c5SAndroid Build Coastguard Worker // EXT_blend_func_extended secondary outputs (ones with index 1) 944*8975f5c5SAndroid Build Coastguard Worker std::vector<VariableLocation> mSecondaryOutputLocations; 945*8975f5c5SAndroid Build Coastguard Worker // Vertex attributes, Fragment input varyings, etc. 946*8975f5c5SAndroid Build Coastguard Worker std::vector<ProgramInput> mProgramInputs; 947*8975f5c5SAndroid Build Coastguard Worker std::vector<TransformFeedbackVarying> mLinkedTransformFeedbackVaryings; 948*8975f5c5SAndroid Build Coastguard Worker // Duplicate of ProgramState::mTransformFeedbackVaryingNames. This is cached here because the 949*8975f5c5SAndroid Build Coastguard Worker // xfb names may change, relink may fail, yet program pipeline link should be able to function 950*8975f5c5SAndroid Build Coastguard Worker // with the last installed executable. In truth, program pipeline link should have been able to 951*8975f5c5SAndroid Build Coastguard Worker // hoist transform feedback varyings directly from the executable, among most other things, but 952*8975f5c5SAndroid Build Coastguard Worker // that is currently not done. 953*8975f5c5SAndroid Build Coastguard Worker // 954*8975f5c5SAndroid Build Coastguard Worker // This array is not serialized, it's already done by the program, and will be duplicated during 955*8975f5c5SAndroid Build Coastguard Worker // deserialization. 956*8975f5c5SAndroid Build Coastguard Worker std::vector<std::string> mTransformFeedbackVaryingNames; 957*8975f5c5SAndroid Build Coastguard Worker // The size of the data written to each transform feedback buffer per vertex. 958*8975f5c5SAndroid Build Coastguard Worker std::vector<GLsizei> mTransformFeedbackStrides; 959*8975f5c5SAndroid Build Coastguard Worker // Uniforms are sorted in order: 960*8975f5c5SAndroid Build Coastguard Worker // 1. Non-opaque uniforms 961*8975f5c5SAndroid Build Coastguard Worker // 2. Sampler uniforms 962*8975f5c5SAndroid Build Coastguard Worker // 3. Image uniforms 963*8975f5c5SAndroid Build Coastguard Worker // 4. Atomic counter uniforms 964*8975f5c5SAndroid Build Coastguard Worker // 5. Uniform block uniforms 965*8975f5c5SAndroid Build Coastguard Worker // This makes opaque uniform validation easier, since we don't need a separate list. 966*8975f5c5SAndroid Build Coastguard Worker // For generating the entries and naming them we follow the spec: GLES 3.1 November 2016 section 967*8975f5c5SAndroid Build Coastguard Worker // 7.3.1.1 Naming Active Resources. There's a separate entry for each struct member and each 968*8975f5c5SAndroid Build Coastguard Worker // inner array of an array of arrays. Names and mapped names of uniforms that are arrays include 969*8975f5c5SAndroid Build Coastguard Worker // [0] in the end. This makes implementation of queries simpler. 970*8975f5c5SAndroid Build Coastguard Worker std::vector<LinkedUniform> mUniforms; 971*8975f5c5SAndroid Build Coastguard Worker std::vector<std::string> mUniformNames; 972*8975f5c5SAndroid Build Coastguard Worker // Only used by GL and D3D backend 973*8975f5c5SAndroid Build Coastguard Worker std::vector<std::string> mUniformMappedNames; 974*8975f5c5SAndroid Build Coastguard Worker std::vector<InterfaceBlock> mUniformBlocks; 975*8975f5c5SAndroid Build Coastguard Worker std::vector<VariableLocation> mUniformLocations; 976*8975f5c5SAndroid Build Coastguard Worker 977*8975f5c5SAndroid Build Coastguard Worker std::vector<AtomicCounterBuffer> mAtomicCounterBuffers; 978*8975f5c5SAndroid Build Coastguard Worker std::vector<InterfaceBlock> mShaderStorageBlocks; 979*8975f5c5SAndroid Build Coastguard Worker std::vector<BufferVariable> mBufferVariables; 980*8975f5c5SAndroid Build Coastguard Worker 981*8975f5c5SAndroid Build Coastguard Worker // An array of the samplers that are used by the program 982*8975f5c5SAndroid Build Coastguard Worker std::vector<SamplerBinding> mSamplerBindings; 983*8975f5c5SAndroid Build Coastguard Worker // List of all textures bound to all samplers. Each SamplerBinding will point to a subset in 984*8975f5c5SAndroid Build Coastguard Worker // this vector. 985*8975f5c5SAndroid Build Coastguard Worker std::vector<GLuint> mSamplerBoundTextureUnits; 986*8975f5c5SAndroid Build Coastguard Worker 987*8975f5c5SAndroid Build Coastguard Worker // An array of the images that are used by the program 988*8975f5c5SAndroid Build Coastguard Worker std::vector<ImageBinding> mImageBindings; 989*8975f5c5SAndroid Build Coastguard Worker 990*8975f5c5SAndroid Build Coastguard Worker // ANGLE_shader_pixel_local_storage: A mapping from binding index to the PLS uniform format at 991*8975f5c5SAndroid Build Coastguard Worker // that index. 992*8975f5c5SAndroid Build Coastguard Worker std::vector<ShPixelLocalStorageFormat> mPixelLocalStorageFormats; 993*8975f5c5SAndroid Build Coastguard Worker 994*8975f5c5SAndroid Build Coastguard Worker ShaderMap<std::vector<sh::ShaderVariable>> mLinkedOutputVaryings; 995*8975f5c5SAndroid Build Coastguard Worker ShaderMap<std::vector<sh::ShaderVariable>> mLinkedInputVaryings; 996*8975f5c5SAndroid Build Coastguard Worker ShaderMap<std::vector<sh::ShaderVariable>> mLinkedUniforms; 997*8975f5c5SAndroid Build Coastguard Worker ShaderMap<std::vector<sh::InterfaceBlock>> mLinkedUniformBlocks; 998*8975f5c5SAndroid Build Coastguard Worker 999*8975f5c5SAndroid Build Coastguard Worker // Cached value of base vertex and base instance 1000*8975f5c5SAndroid Build Coastguard Worker // need to reset them to zero if using non base vertex or base instance draw calls. 1001*8975f5c5SAndroid Build Coastguard Worker GLint mCachedBaseVertex; 1002*8975f5c5SAndroid Build Coastguard Worker GLuint mCachedBaseInstance; 1003*8975f5c5SAndroid Build Coastguard Worker 1004*8975f5c5SAndroid Build Coastguard Worker // GLES allows uniform block indices in the program to be remapped to arbitrary buffer bindings 1005*8975f5c5SAndroid Build Coastguard Worker // through calls to glUniformBlockBinding. (Desktop GL also includes 1006*8975f5c5SAndroid Build Coastguard Worker // glShaderStorageBlockBinding, which does not exist in GLES). 1007*8975f5c5SAndroid Build Coastguard Worker // This is not a part of the link results, and must be reset on glProgramBinary, so it's not 1008*8975f5c5SAndroid Build Coastguard Worker // serialized. 1009*8975f5c5SAndroid Build Coastguard Worker // A map from the program uniform block index to the buffer binding it is mapped to. 1010*8975f5c5SAndroid Build Coastguard Worker ProgramUniformBlockArray<GLuint> mUniformBlockIndexToBufferBinding; 1011*8975f5c5SAndroid Build Coastguard Worker // The reverse of the above map, i.e. from buffer bindings to the uniform blocks that are mapped 1012*8975f5c5SAndroid Build Coastguard Worker // to it. For example, if the program's uniform blocks 1, 3 and 4 are mapped to buffer binding 1013*8975f5c5SAndroid Build Coastguard Worker // 2, then mUniformBufferBindingToUniformBlocks[2] will be {1, 3, 4}. 1014*8975f5c5SAndroid Build Coastguard Worker // 1015*8975f5c5SAndroid Build Coastguard Worker // This is used to efficiently mark uniform blocks dirty when a buffer bound to a binding has 1016*8975f5c5SAndroid Build Coastguard Worker // been modified. 1017*8975f5c5SAndroid Build Coastguard Worker UniformBufferBindingArray<ProgramUniformBlockMask> mUniformBufferBindingToUniformBlocks; 1018*8975f5c5SAndroid Build Coastguard Worker 1019*8975f5c5SAndroid Build Coastguard Worker // PPO only: installed executables from the programs. Note that these may be different from the 1020*8975f5c5SAndroid Build Coastguard Worker // programs' current executables, because they may have been unsuccessfully relinked. 1021*8975f5c5SAndroid Build Coastguard Worker ShaderMap<SharedProgramExecutable> mPPOProgramExecutables; 1022*8975f5c5SAndroid Build Coastguard Worker // Flag for an easy check for PPO without inspecting mPPOProgramExecutables 1023*8975f5c5SAndroid Build Coastguard Worker bool mIsPPO; 1024*8975f5c5SAndroid Build Coastguard Worker 1025*8975f5c5SAndroid Build Coastguard Worker // Cache for sampler validation 1026*8975f5c5SAndroid Build Coastguard Worker mutable Optional<bool> mCachedValidateSamplersResult; 1027*8975f5c5SAndroid Build Coastguard Worker 1028*8975f5c5SAndroid Build Coastguard Worker // Post-link subtask and wait events 1029*8975f5c5SAndroid Build Coastguard Worker // These tasks are not waited on in |resolveLink|, but instead they are free to 1030*8975f5c5SAndroid Build Coastguard Worker // run until first usage of the program (or relink). This is used by the backends (currently 1031*8975f5c5SAndroid Build Coastguard Worker // only Vulkan) to run post-link optimization tasks which don't affect the link results. 1032*8975f5c5SAndroid Build Coastguard Worker mutable std::vector<std::shared_ptr<rx::LinkSubTask>> mPostLinkSubTasks; 1033*8975f5c5SAndroid Build Coastguard Worker mutable std::vector<std::shared_ptr<angle::WaitableEvent>> mPostLinkSubTaskWaitableEvents; 1034*8975f5c5SAndroid Build Coastguard Worker }; 1035*8975f5c5SAndroid Build Coastguard Worker 1036*8975f5c5SAndroid Build Coastguard Worker void InstallExecutable(const Context *context, 1037*8975f5c5SAndroid Build Coastguard Worker const SharedProgramExecutable &toInstall, 1038*8975f5c5SAndroid Build Coastguard Worker SharedProgramExecutable *executable); 1039*8975f5c5SAndroid Build Coastguard Worker void UninstallExecutable(const Context *context, SharedProgramExecutable *executable); 1040*8975f5c5SAndroid Build Coastguard Worker } // namespace gl 1041*8975f5c5SAndroid Build Coastguard Worker 1042*8975f5c5SAndroid Build Coastguard Worker #endif // LIBANGLE_PROGRAMEXECUTABLE_H_ 1043