Hash :
3e14e2b1
Author :
Date :
2015-10-29T14:38:53
D3D11: Fix basic provoking vertex flat shading cases. The enables geometry shaders that correct for the flat shading on provoking vertexes. It does not fix it for triangle strips, or in conjunction with primitive restart (which is not yet implemented in D3D11). Also ensure we do not regress with flat shading enabled and transform feedback. In cases where we use flat shading, do a double draw call, first with an untransformed vertex stream, and no geometry shader, then with the geometry shader enabled. This also fixes the dEQP fragment output tests with ints. BUG=angleproject:754 Change-Id: Ib37e8ec32d19db17ea5d4dc88158cdae0c956bfc Reviewed-on: https://chromium-review.googlesource.com/309155 Tryjob-Request: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
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
//
// Copyright (c) 2014 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.
//
// DynamicHLSL.h: Interface for link and run-time HLSL generation
//
#ifndef LIBANGLE_RENDERER_D3D_DYNAMICHLSL_H_
#define LIBANGLE_RENDERER_D3D_DYNAMICHLSL_H_
#include <map>
#include <vector>
#include "angle_gl.h"
#include "common/angleutils.h"
#include "libANGLE/Constants.h"
#include "libANGLE/Program.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/d3d/RendererD3D.h"
namespace sh
{
struct Attribute;
struct ShaderVariable;
}
namespace gl
{
class InfoLog;
struct VariableLocation;
struct LinkedVarying;
struct VertexAttribute;
struct Data;
}
namespace rx
{
class ShaderD3D;
struct PixelShaderOutputVariable
{
GLenum type;
std::string name;
std::string source;
size_t outputIndex;
};
struct PackedVarying
{
PackedVarying(const sh::Varying &varyingIn)
: varying(&varyingIn), registerIndex(GL_INVALID_INDEX), columnIndex(0), vertexOnly(false)
{
}
bool registerAssigned() const { return registerIndex != GL_INVALID_INDEX; }
void resetRegisterAssignment() { registerIndex = GL_INVALID_INDEX; }
const sh::Varying *varying;
// Assigned during link
unsigned int registerIndex;
// Assigned during link, Defaults to 0
unsigned int columnIndex;
// Transform feedback varyings can be only referenced in the VS.
bool vertexOnly;
};
class DynamicHLSL : angle::NonCopyable
{
public:
explicit DynamicHLSL(RendererD3D *const renderer);
bool packVaryings(const gl::Caps &caps,
gl::InfoLog &infoLog,
std::vector<PackedVarying> *packedVaryings,
const std::vector<std::string> &transformFeedbackVaryings,
unsigned int *registerCountOut);
std::string generateVertexShaderForInputLayout(
const std::string &sourceShader,
const gl::InputLayout &inputLayout,
const std::vector<sh::Attribute> &shaderAttributes) const;
std::string generatePixelShaderForOutputSignature(
const std::string &sourceShader,
const std::vector<PixelShaderOutputVariable> &outputVariables,
bool usesFragDepth,
const std::vector<GLenum> &outputLayout) const;
bool generateShaderLinkHLSL(const gl::Data &data,
const gl::Program::Data &programData,
gl::InfoLog &infoLog,
unsigned int registerCount,
std::string *pixelHLSL,
std::string *vertexHLSL,
const std::vector<PackedVarying> &packedVaryings,
std::vector<gl::LinkedVarying> *linkedVaryings,
std::vector<PixelShaderOutputVariable> *outPixelShaderKey,
bool *outUsesFragDepth) const;
std::string generateGeometryShaderPreamble(
const gl::Data &data,
const gl::Program::Data &programData,
unsigned int registers,
const std::vector<PackedVarying> &packedVaryings) const;
std::string generateGeometryShaderHLSL(gl::PrimitiveType primitiveType,
const gl::Data &data,
const gl::Program::Data &programData,
const std::string &preambleString) const;
private:
RendererD3D *const mRenderer;
struct SemanticInfo;
std::string getVaryingSemantic(bool programUsesPointSize) const;
SemanticInfo getSemanticInfo(ShaderType shaderType,
unsigned int startRegisters,
bool position,
bool fragCoord,
bool pointCoord,
bool pointSize) const;
void generateVaryingLinkHLSL(const gl::Caps &caps,
bool programUsesPointSize,
const SemanticInfo &info,
const std::vector<PackedVarying> &packedVaryings,
std::stringstream &linkStream) const;
void generateVaryingHLSL(const gl::Caps &caps,
const std::vector<PackedVarying> &varyings,
bool programUsesPointSize,
std::stringstream &hlslStream) const;
void storeUserLinkedVaryings(const std::vector<PackedVarying> &packedVaryings,
bool programUsesPointSize,
std::vector<gl::LinkedVarying> *linkedVaryings) const;
void storeBuiltinLinkedVaryings(const SemanticInfo &info,
std::vector<gl::LinkedVarying> *linkedVaryings) const;
// Prepend an underscore
static std::string decorateVariable(const std::string &name);
std::string generateAttributeConversionHLSL(gl::VertexFormatType vertexFormatType,
const sh::ShaderVariable &shaderAttrib) const;
};
}
#endif // LIBANGLE_RENDERER_D3D_DYNAMICHLSL_H_