Hash :
9c4c0926
Author :
Date :
2018-06-13T09:29:00
Reland "GLES1: Point rasterization (partial implementation)" This is a reland of 4004ae0e033a0169de3cb53c0a036833ad47178a Fix: Put the missing early-out in ValidatePointParameterCommon Original change's description: > GLES1: Point rasterization (partial implementation) > > - Not included: Smooth points > > - GL_OES_point_sprite > - Update test expectations. Note: due to different random sampling, > edge cases were hit in UserClip. Disabling that test for now. > > BUG=angleproject:2306 > > Change-Id: If8367bc3321804b3299d3bc381d6a8e236754baa > Reviewed-on: https://chromium-review.googlesource.com/1101910 > Reviewed-by: Corentin Wallez <cwallez@chromium.org> > Commit-Queue: Lingfeng Yang <lfy@google.com> Bug: angleproject:2306 Change-Id: Id8e71352a77ff0ce71cb604965effbfb8aca613e Reviewed-on: https://chromium-review.googlesource.com/1108458 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Lingfeng Yang <lfy@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 219 220 221 222 223 224 225 226 227 228 229 230 231
//
// Copyright 2018 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.
//
// GLES1Renderer.h: Defines GLES1 emulation rendering operations on top of a GLES3
// context. Used by Context.h.
#ifndef LIBANGLE_GLES1_RENDERER_H_
#define LIBANGLE_GLES1_RENDERER_H_
#include "angle_gl.h"
#include "common/angleutils.h"
#include "libANGLE/angletypes.h"
#include <memory>
#include <string>
#include <unordered_map>
namespace gl
{
class Context;
class Program;
class State;
class Shader;
class ShaderProgramManager;
class GLES1Renderer final : angle::NonCopyable
{
public:
GLES1Renderer();
~GLES1Renderer();
void onDestroy(Context *context, State *state);
Error prepareForDraw(PrimitiveMode mode, Context *context, State *glState);
int vertexArrayIndex(ClientVertexArrayType type, const State *glState) const;
static int TexCoordArrayIndex(unsigned int unit);
AttributesMask getVertexArraysAttributeMask(const State *glState) const;
private:
using Mat4Uniform = float[16];
using Vec4Uniform = float[4];
using Vec3Uniform = float[3];
Shader *getShader(GLuint handle) const;
Program *getProgram(GLuint handle) const;
Error compileShader(Context *context,
ShaderType shaderType,
const char *src,
GLuint *shaderOut);
Error linkProgram(Context *context,
State *glState,
GLuint vshader,
GLuint fshader,
const std::unordered_map<GLint, std::string> &attribLocs,
GLuint *programOut);
Error initializeRendererProgram(Context *context, State *glState);
void setUniform1i(Program *programObject, GLint loc, GLint value);
void setUniform1iv(Program *programObject, GLint loc, GLint count, const GLint *value);
void setUniformMatrix4fv(Program *programObject,
GLint loc,
GLint count,
GLboolean transpose,
const GLfloat *value);
void setUniform4fv(Program *programObject, GLint loc, GLint count, const GLfloat *value);
void setUniform3fv(Program *programObject, GLint loc, GLint count, const GLfloat *value);
void setUniform1f(Program *programObject, GLint loc, GLfloat value);
void setUniform1fv(Program *programObject, GLint loc, GLint count, const GLfloat *value);
static constexpr int kTexUnitCount = 4;
static constexpr int kLightCount = 8;
static constexpr int kClipPlaneCount = 6;
static constexpr int kVertexAttribIndex = 0;
static constexpr int kNormalAttribIndex = 1;
static constexpr int kColorAttribIndex = 2;
static constexpr int kPointSizeAttribIndex = 3;
static constexpr int kTextureCoordAttribIndexBase = 4;
bool mRendererProgramInitialized;
ShaderProgramManager *mShaderPrograms;
struct GLES1ProgramState
{
GLuint program;
GLint projMatrixLoc;
GLint modelviewMatrixLoc;
GLint textureMatrixLoc;
GLint modelviewInvTrLoc;
// Texturing
GLint enableTexture2DLoc;
GLint enableTextureCubeMapLoc;
std::array<GLint, kTexUnitCount> tex2DSamplerLocs;
std::array<GLint, kTexUnitCount> texCubeSamplerLocs;
GLint textureFormatLoc;
GLint textureEnvModeLoc;
GLint combineRgbLoc;
GLint combineAlphaLoc;
GLint src0rgbLoc;
GLint src0alphaLoc;
GLint src1rgbLoc;
GLint src1alphaLoc;
GLint src2rgbLoc;
GLint src2alphaLoc;
GLint op0rgbLoc;
GLint op0alphaLoc;
GLint op1rgbLoc;
GLint op1alphaLoc;
GLint op2rgbLoc;
GLint op2alphaLoc;
GLint textureEnvColorLoc;
GLint rgbScaleLoc;
GLint alphaScaleLoc;
GLint pointSpriteCoordReplaceLoc;
// Alpha test
GLint enableAlphaTestLoc;
GLint alphaFuncLoc;
GLint alphaTestRefLoc;
// Shading, materials, and lighting
GLint shadeModelFlatLoc;
GLint enableLightingLoc;
GLint enableRescaleNormalLoc;
GLint enableNormalizeLoc;
GLint enableColorMaterialLoc;
GLint materialAmbientLoc;
GLint materialDiffuseLoc;
GLint materialSpecularLoc;
GLint materialEmissiveLoc;
GLint materialSpecularExponentLoc;
GLint lightModelSceneAmbientLoc;
GLint lightModelTwoSidedLoc;
GLint lightEnablesLoc;
GLint lightAmbientsLoc;
GLint lightDiffusesLoc;
GLint lightSpecularsLoc;
GLint lightPositionsLoc;
GLint lightDirectionsLoc;
GLint lightSpotlightExponentsLoc;
GLint lightSpotlightCutoffAnglesLoc;
GLint lightAttenuationConstsLoc;
GLint lightAttenuationLinearsLoc;
GLint lightAttenuationQuadraticsLoc;
// Fog
GLint fogEnableLoc;
GLint fogModeLoc;
GLint fogDensityLoc;
GLint fogStartLoc;
GLint fogEndLoc;
GLint fogColorLoc;
// Clip planes
GLint enableClipPlanesLoc;
GLint clipPlaneEnablesLoc;
GLint clipPlanesLoc;
// Point rasterization
GLint pointRasterizationLoc;
GLint pointSizeMinLoc;
GLint pointSizeMaxLoc;
GLint pointDistanceAttenuationLoc;
GLint pointSpriteEnabledLoc;
};
struct GLES1UniformBuffers
{
std::array<Mat4Uniform, kTexUnitCount> textureMatrices;
std::array<GLint, kTexUnitCount> tex2DEnables;
std::array<GLint, kTexUnitCount> texCubeEnables;
std::array<GLint, kTexUnitCount> texEnvModes;
std::array<GLint, kTexUnitCount> texCombineRgbs;
std::array<GLint, kTexUnitCount> texCombineAlphas;
std::array<GLint, kTexUnitCount> texCombineSrc0Rgbs;
std::array<GLint, kTexUnitCount> texCombineSrc0Alphas;
std::array<GLint, kTexUnitCount> texCombineSrc1Rgbs;
std::array<GLint, kTexUnitCount> texCombineSrc1Alphas;
std::array<GLint, kTexUnitCount> texCombineSrc2Rgbs;
std::array<GLint, kTexUnitCount> texCombineSrc2Alphas;
std::array<GLint, kTexUnitCount> texCombineOp0Rgbs;
std::array<GLint, kTexUnitCount> texCombineOp0Alphas;
std::array<GLint, kTexUnitCount> texCombineOp1Rgbs;
std::array<GLint, kTexUnitCount> texCombineOp1Alphas;
std::array<GLint, kTexUnitCount> texCombineOp2Rgbs;
std::array<GLint, kTexUnitCount> texCombineOp2Alphas;
std::array<Vec4Uniform, kTexUnitCount> texEnvColors;
std::array<GLfloat, kTexUnitCount> texEnvRgbScales;
std::array<GLfloat, kTexUnitCount> texEnvAlphaScales;
std::array<GLint, kTexUnitCount> pointSpriteCoordReplaces;
// Lighting
std::array<GLint, kLightCount> lightEnables;
std::array<Vec4Uniform, kLightCount> lightAmbients;
std::array<Vec4Uniform, kLightCount> lightDiffuses;
std::array<Vec4Uniform, kLightCount> lightSpeculars;
std::array<Vec4Uniform, kLightCount> lightPositions;
std::array<Vec3Uniform, kLightCount> lightDirections;
std::array<GLfloat, kLightCount> spotlightExponents;
std::array<GLfloat, kLightCount> spotlightCutoffAngles;
std::array<GLfloat, kLightCount> attenuationConsts;
std::array<GLfloat, kLightCount> attenuationLinears;
std::array<GLfloat, kLightCount> attenuationQuadratics;
// Clip planes
std::array<GLint, kClipPlaneCount> clipPlaneEnables;
std::array<Vec4Uniform, kClipPlaneCount> clipPlanes;
};
GLES1UniformBuffers mUniformBuffers;
GLES1ProgramState mProgramState;
};
} // namespace gl
#endif // LIBANGLE_GLES1_RENDERER_H_