зеркало из https://github.com/AvaloniaUI/angle.git
Adding support for OES_standard_derivatives extension. This is not the complete implementation. Sending it to get feedback on the API. Is it OK to add extension support into TBuiltInResource? I could create a new struct for extensions but that would lead to API change.
BUG=25 Review URL: http://codereview.appspot.com/1953047 git-svn-id: https://angleproject.googlecode.com/svn/trunk@402 736b8ea6-26fd-11df-bfd4-992fa37f6226
This commit is contained in:
Родитель
575e7910ff
Коммит
94a86ad8f1
|
@ -1,21 +0,0 @@
|
|||
//
|
||||
// Copyright (c) 2002-2010 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.
|
||||
//
|
||||
|
||||
#ifndef _RESOURCE_LIMITS_INCLUDED_
|
||||
#define _RESOURCE_LIMITS_INCLUDED_
|
||||
|
||||
struct TBuiltInResource
|
||||
{
|
||||
int maxVertexAttribs;
|
||||
int maxVertexUniformVectors;
|
||||
int maxVaryingVectors;
|
||||
int maxVertexTextureImageUnits;
|
||||
int maxCombinedTextureImageUnits;
|
||||
int maxTextureImageUnits;
|
||||
int maxFragmentUniformVectors;
|
||||
int maxDrawBuffers;
|
||||
};
|
||||
#endif // _RESOURCE_LIMITS_INCLUDED_
|
|
@ -6,8 +6,6 @@
|
|||
#ifndef _COMPILER_INTERFACE_INCLUDED_
|
||||
#define _COMPILER_INTERFACE_INCLUDED_
|
||||
|
||||
#include "ResourceLimits.h"
|
||||
|
||||
//
|
||||
// This is the platform independent interface between an OGL driver
|
||||
// and the shading language compiler.
|
||||
|
@ -45,6 +43,32 @@ typedef enum {
|
|||
EShSpecWebGL,
|
||||
} EShSpec;
|
||||
|
||||
//
|
||||
// Implementation dependent built-in resources (constants and extensions).
|
||||
// The names for these resources has been obtained by stripping gl_/GL_.
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
// Constants.
|
||||
int MaxVertexAttribs;
|
||||
int MaxVertexUniformVectors;
|
||||
int MaxVaryingVectors;
|
||||
int MaxVertexTextureImageUnits;
|
||||
int MaxCombinedTextureImageUnits;
|
||||
int MaxTextureImageUnits;
|
||||
int MaxFragmentUniformVectors;
|
||||
int MaxDrawBuffers;
|
||||
|
||||
// Extensions.
|
||||
// Set to 1 to enable the extension, else 0.
|
||||
int OES_standard_derivatives;
|
||||
} TBuiltInResource;
|
||||
|
||||
//
|
||||
// Initialize built-in resources with minimum expected values.
|
||||
//
|
||||
void ShInitBuiltInResource(TBuiltInResource* resources);
|
||||
|
||||
//
|
||||
// Optimization level for the compiler.
|
||||
//
|
||||
|
|
|
@ -34,16 +34,20 @@ int OutputMultipleStrings = 1;
|
|||
//
|
||||
// Set up the per compile resources
|
||||
//
|
||||
void GenerateResources(TBuiltInResource& resources)
|
||||
void GenerateResources(TBuiltInResource* resources)
|
||||
{
|
||||
resources.maxVertexAttribs = 8;
|
||||
resources.maxVertexUniformVectors = 128;
|
||||
resources.maxVaryingVectors = 8;
|
||||
resources.maxVertexTextureImageUnits = 0;
|
||||
resources.maxCombinedTextureImageUnits = 8;
|
||||
resources.maxTextureImageUnits = 8;
|
||||
resources.maxFragmentUniformVectors = 16;
|
||||
resources.maxDrawBuffers = 1;
|
||||
ShInitBuiltInResource(resources);
|
||||
|
||||
resources->MaxVertexAttribs = 8;
|
||||
resources->MaxVertexUniformVectors = 128;
|
||||
resources->MaxVaryingVectors = 8;
|
||||
resources->MaxVertexTextureImageUnits = 0;
|
||||
resources->MaxCombinedTextureImageUnits = 8;
|
||||
resources->MaxTextureImageUnits = 8;
|
||||
resources->MaxFragmentUniformVectors = 16;
|
||||
resources->MaxDrawBuffers = 1;
|
||||
|
||||
resources->OES_standard_derivatives = 0;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
|
@ -60,7 +64,7 @@ int main(int argc, char* argv[])
|
|||
ShInitialize();
|
||||
|
||||
TBuiltInResource resources;
|
||||
GenerateResources(resources);
|
||||
GenerateResources(&resources);
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
|
|
|
@ -472,15 +472,15 @@ static TString BuiltInConstants(const TBuiltInResource &resources)
|
|||
{
|
||||
TStringStream s;
|
||||
|
||||
s << "const int gl_MaxVertexAttribs = " << resources.maxVertexAttribs << ";";
|
||||
s << "const int gl_MaxVertexUniformVectors = " << resources.maxVertexUniformVectors << ";";
|
||||
s << "const int gl_MaxVertexAttribs = " << resources.MaxVertexAttribs << ";";
|
||||
s << "const int gl_MaxVertexUniformVectors = " << resources.MaxVertexUniformVectors << ";";
|
||||
|
||||
s << "const int gl_MaxVaryingVectors = " << resources.maxVaryingVectors << ";";
|
||||
s << "const int gl_MaxVertexTextureImageUnits = " << resources.maxVertexTextureImageUnits << ";";
|
||||
s << "const int gl_MaxCombinedTextureImageUnits = " << resources.maxCombinedTextureImageUnits << ";";
|
||||
s << "const int gl_MaxTextureImageUnits = " << resources.maxTextureImageUnits << ";";
|
||||
s << "const int gl_MaxFragmentUniformVectors = " << resources.maxFragmentUniformVectors << ";";
|
||||
s << "const int gl_MaxDrawBuffers = " << resources.maxDrawBuffers << ";";
|
||||
s << "const int gl_MaxVaryingVectors = " << resources.MaxVaryingVectors << ";";
|
||||
s << "const int gl_MaxVertexTextureImageUnits = " << resources.MaxVertexTextureImageUnits << ";";
|
||||
s << "const int gl_MaxCombinedTextureImageUnits = " << resources.MaxCombinedTextureImageUnits << ";";
|
||||
s << "const int gl_MaxTextureImageUnits = " << resources.MaxTextureImageUnits << ";";
|
||||
s << "const int gl_MaxFragmentUniformVectors = " << resources.MaxFragmentUniformVectors << ";";
|
||||
s << "const int gl_MaxDrawBuffers = " << resources.MaxDrawBuffers << ";";
|
||||
|
||||
return s.str();
|
||||
}
|
||||
|
@ -607,7 +607,7 @@ void IdentifyBuiltIns(EShLanguage language, EShSpec spec, const TBuiltInResource
|
|||
case EShLangFragment: {
|
||||
// Set up gl_FragData. The array size.
|
||||
TType fragData(EbtFloat, EbpMedium, EvqFragColor, 4, false, true);
|
||||
fragData.setArraySize(resources.maxDrawBuffers);
|
||||
fragData.setArraySize(resources.MaxDrawBuffers);
|
||||
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData));
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
#ifndef _INITIALIZE_INCLUDED_
|
||||
#define _INITIALIZE_INCLUDED_
|
||||
|
||||
#include "GLSLANG/ResourceLimits.h"
|
||||
|
||||
#include "compiler/Common.h"
|
||||
#include "compiler/ShHandle.h"
|
||||
#include "compiler/SymbolTable.h"
|
||||
|
|
|
@ -96,10 +96,39 @@ int ShInitialize()
|
|||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup symbol tables
|
||||
//
|
||||
int ShFinalize()
|
||||
{
|
||||
if (!DetachProcess())
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize built-in resources with minimum expected values.
|
||||
//
|
||||
void ShInitBuiltInResource(TBuiltInResource* resources)
|
||||
{
|
||||
// Constants.
|
||||
resources->MaxVertexAttribs = 8;
|
||||
resources->MaxVertexUniformVectors = 128;
|
||||
resources->MaxVaryingVectors = 8;
|
||||
resources->MaxVertexTextureImageUnits = 0;
|
||||
resources->MaxCombinedTextureImageUnits = 8;
|
||||
resources->MaxTextureImageUnits = 8;
|
||||
resources->MaxFragmentUniformVectors = 16;
|
||||
resources->MaxDrawBuffers = 1;
|
||||
|
||||
// Extensions.
|
||||
resources->OES_standard_derivatives = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Driver calls these to create and destroy compiler objects.
|
||||
//
|
||||
|
||||
ShHandle ShConstructCompiler(EShLanguage language, EShSpec spec, const TBuiltInResource* resources)
|
||||
{
|
||||
if (!InitThread())
|
||||
|
@ -130,17 +159,6 @@ void ShDestruct(ShHandle handle)
|
|||
DeleteCompiler(base->getAsCompiler());
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup symbol tables
|
||||
//
|
||||
int ShFinalize()
|
||||
{
|
||||
if (!DetachProcess())
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Do an actual compile on the given strings. The result is left
|
||||
// in the given compile object.
|
||||
|
|
|
@ -35,14 +35,15 @@ Shader::Shader(ResourceManager *manager, GLuint handle) : mHandle(handle), mReso
|
|||
if (result)
|
||||
{
|
||||
TBuiltInResource resources;
|
||||
resources.maxVertexAttribs = MAX_VERTEX_ATTRIBS;
|
||||
resources.maxVertexUniformVectors = MAX_VERTEX_UNIFORM_VECTORS;
|
||||
resources.maxVaryingVectors = MAX_VARYING_VECTORS;
|
||||
resources.maxVertexTextureImageUnits = MAX_VERTEX_TEXTURE_IMAGE_UNITS;
|
||||
resources.maxCombinedTextureImageUnits = MAX_COMBINED_TEXTURE_IMAGE_UNITS;
|
||||
resources.maxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
|
||||
resources.maxFragmentUniformVectors = MAX_FRAGMENT_UNIFORM_VECTORS;
|
||||
resources.maxDrawBuffers = MAX_DRAW_BUFFERS;
|
||||
ShInitBuiltInResource(&resources);
|
||||
resources.MaxVertexAttribs = MAX_VERTEX_ATTRIBS;
|
||||
resources.MaxVertexUniformVectors = MAX_VERTEX_UNIFORM_VECTORS;
|
||||
resources.MaxVaryingVectors = MAX_VARYING_VECTORS;
|
||||
resources.MaxVertexTextureImageUnits = MAX_VERTEX_TEXTURE_IMAGE_UNITS;
|
||||
resources.MaxCombinedTextureImageUnits = MAX_COMBINED_TEXTURE_IMAGE_UNITS;
|
||||
resources.MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
|
||||
resources.MaxFragmentUniformVectors = MAX_FRAGMENT_UNIFORM_VECTORS;
|
||||
resources.MaxDrawBuffers = MAX_DRAW_BUFFERS;
|
||||
|
||||
mFragmentCompiler = ShConstructCompiler(EShLangFragment, EShSpecGLES2, &resources);
|
||||
mVertexCompiler = ShConstructCompiler(EShLangVertex, EShSpecGLES2, &resources);
|
||||
|
|
Загрузка…
Ссылка в новой задаче