Hash :
a4b506f7
Author :
Date :
2020-04-03T18:31:22
No-Op draws when no active VS and/or FS is present According to the OpenGL ES 3.1 spec: 7.3. PROGRAM OBJECTS If there is no active program for the vertex or fragment shader stages, the results of vertex and fragment shader execution will respectively be undefined. However, this is not an error. To handle this, if no VS or FS is present in the active Program/PPO, we will no-op the draw command. Bug: angleproject:3570 Test: KHR-GLES31.core.sepshaderobjs.StateInteraction Change-Id: If19e9fbb1bc09fa0d490832079bb9f514eab6035 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2136386 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Tim Van Patten <timvp@google.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ProgramExecutable.h: Collects the information and interfaces common to both Programs and
// ProgramPipelines in order to execute/draw with either.
#ifndef LIBANGLE_PROGRAMEXECUTABLE_H_
#define LIBANGLE_PROGRAMEXECUTABLE_H_
#include "BinaryStream.h"
#include "libANGLE/Caps.h"
#include "libANGLE/InfoLog.h"
#include "libANGLE/VaryingPacking.h"
#include "libANGLE/angletypes.h"
namespace gl
{
// This small structure encapsulates binding sampler uniforms to active GL textures.
struct SamplerBinding
{
SamplerBinding(TextureType textureTypeIn,
SamplerFormat formatIn,
size_t elementCount,
bool unreferenced);
SamplerBinding(const SamplerBinding &other);
~SamplerBinding();
// Necessary for retrieving active textures from the GL state.
TextureType textureType;
SamplerFormat format;
// List of all textures bound to this sampler, of type textureType.
std::vector<GLuint> boundTextureUnits;
// A note if this sampler is an unreferenced uniform.
bool unreferenced;
};
struct ImageBinding
{
ImageBinding(size_t count);
ImageBinding(GLuint imageUnit, size_t count, bool unreferenced);
ImageBinding(const ImageBinding &other);
~ImageBinding();
std::vector<GLuint> boundImageUnits;
// A note if this image unit is an unreferenced uniform.
bool unreferenced;
};
class ProgramState;
class ProgramPipelineState;
class ProgramExecutable
{
public:
ProgramExecutable();
virtual ~ProgramExecutable();
void reset();
void save(gl::BinaryOutputStream *stream) const;
void load(gl::BinaryInputStream *stream);
const ProgramState *getProgramState(ShaderType shaderType) const;
int getInfoLogLength() const;
InfoLog &getInfoLog() { return mInfoLog; }
void getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog) const;
std::string getInfoLogString() const;
void resetInfoLog() { mInfoLog.reset(); }
void resetLinkedShaderStages()
{
mLinkedComputeShaderStages.reset();
mLinkedGraphicsShaderStages.reset();
}
const ShaderBitSet &getLinkedShaderStages() const
{
return isCompute() ? mLinkedComputeShaderStages : mLinkedGraphicsShaderStages;
}
void setLinkedShaderStages(ShaderType shaderType)
{
if (shaderType == ShaderType::Compute)
{
mLinkedComputeShaderStages.set(ShaderType::Compute);
}
else
{
mLinkedGraphicsShaderStages.set(shaderType);
}
updateCanDrawWith();
}
bool hasLinkedShaderStage(ShaderType shaderType) const
{
ASSERT(shaderType != ShaderType::InvalidEnum);
return (shaderType == ShaderType::Compute) ? mLinkedComputeShaderStages[shaderType]
: mLinkedGraphicsShaderStages[shaderType];
}
size_t getLinkedShaderStageCount() const
{
return isCompute() ? mLinkedComputeShaderStages.count()
: mLinkedGraphicsShaderStages.count();
}
bool isCompute() const;
const AttributesMask &getActiveAttribLocationsMask() const
{
return mActiveAttribLocationsMask;
}
bool isAttribLocationActive(size_t attribLocation) const;
const AttributesMask &getNonBuiltinAttribLocationsMask() const { return mAttributesMask; }
unsigned int getMaxActiveAttribLocation() const { return mMaxActiveAttribLocation; }
const ComponentTypeMask &getAttributesTypeMask() const { return mAttributesTypeMask; }
AttributesMask getAttributesMask() const;
const ActiveTextureMask &getActiveSamplersMask() const { return mActiveSamplersMask; }
SamplerFormat getSamplerFormatForTextureUnitIndex(size_t textureUnitIndex) const
{
return mActiveSamplerFormats[textureUnitIndex];
}
const ShaderBitSet getSamplerShaderBitsForTextureUnitIndex(size_t textureUnitIndex) const
{
return mActiveSamplerShaderBits[textureUnitIndex];
}
const ActiveTextureMask &getActiveImagesMask() const { return mActiveImagesMask; }
const ActiveTextureArray<ShaderBitSet> &getActiveImageShaderBits() const
{
return mActiveImageShaderBits;
}
const ActiveTextureArray<TextureType> &getActiveSamplerTypes() const
{
return mActiveSamplerTypes;
}
bool hasDefaultUniforms() const;
bool hasTextures() const;
bool hasUniformBuffers() const;
bool hasStorageBuffers() const;
bool hasAtomicCounterBuffers() const;
bool hasImages() const;
bool hasTransformFeedbackOutput() const;
// Count the number of uniform and storage buffer declarations, counting arrays as one.
size_t getTransformFeedbackBufferCount(const gl::State &glState) const;
bool linkValidateGlobalNames(InfoLog &infoLog) const;
// TODO: http://anglebug.com/4520: Remove mProgramState/mProgramPipelineState
void setProgramState(ProgramState *state)
{
ASSERT(!mProgramState && !mProgramPipelineState);
mProgramState = state;
}
void setProgramPipelineState(ProgramPipelineState *state)
{
ASSERT(!mProgramState && !mProgramPipelineState);
mProgramPipelineState = state;
}
void setIsCompute(bool isComputeIn);
void updateCanDrawWith();
bool hasVertexAndFragmentShader() const { return mCanDrawWith; }
private:
// TODO(timvp): http://anglebug.com/3570: Investigate removing these friend
// class declarations and accessing the necessary members with getters/setters.
friend class Program;
friend class ProgramPipeline;
friend class ProgramState;
void updateActiveSamplers(const ProgramState &programState);
void updateActiveImages(std::vector<ImageBinding> &imageBindings);
// Scans the sampler bindings for type conflicts with sampler 'textureUnitIndex'.
void setSamplerUniformTextureTypeAndFormat(size_t textureUnitIndex,
std::vector<SamplerBinding> &samplerBindings);
// TODO: http://anglebug.com/4520: Remove mProgramState/mProgramPipelineState
ProgramState *mProgramState;
ProgramPipelineState *mProgramPipelineState;
InfoLog mInfoLog;
ShaderBitSet mLinkedGraphicsShaderStages;
ShaderBitSet mLinkedComputeShaderStages;
angle::BitSet<MAX_VERTEX_ATTRIBS> mActiveAttribLocationsMask;
unsigned int mMaxActiveAttribLocation;
ComponentTypeMask mAttributesTypeMask;
// mAttributesMask is identical to mActiveAttribLocationsMask with built-in attributes removed.
AttributesMask mAttributesMask;
// Cached mask of active samplers and sampler types.
ActiveTextureMask mActiveSamplersMask;
ActiveTextureArray<uint32_t> mActiveSamplerRefCounts;
ActiveTextureArray<TextureType> mActiveSamplerTypes;
ActiveTextureArray<SamplerFormat> mActiveSamplerFormats;
ActiveTextureArray<ShaderBitSet> mActiveSamplerShaderBits;
// Cached mask of active images.
ActiveTextureMask mActiveImagesMask;
ActiveTextureArray<ShaderBitSet> mActiveImageShaderBits;
bool mCanDrawWith;
};
} // namespace gl
#endif // LIBANGLE_PROGRAMEXECUTABLE_H_