Commit 94a86ad8 by alokp@chromium.org

Adding support for OES_standard_derivatives extension. This is not the complete…

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
parent 575e7910
//
// 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 @@ ...@@ -6,8 +6,6 @@
#ifndef _COMPILER_INTERFACE_INCLUDED_ #ifndef _COMPILER_INTERFACE_INCLUDED_
#define _COMPILER_INTERFACE_INCLUDED_ #define _COMPILER_INTERFACE_INCLUDED_
#include "ResourceLimits.h"
// //
// This is the platform independent interface between an OGL driver // This is the platform independent interface between an OGL driver
// and the shading language compiler. // and the shading language compiler.
...@@ -46,6 +44,32 @@ typedef enum { ...@@ -46,6 +44,32 @@ typedef enum {
} EShSpec; } 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. // Optimization level for the compiler.
// //
typedef enum { typedef enum {
......
...@@ -34,16 +34,20 @@ int OutputMultipleStrings = 1; ...@@ -34,16 +34,20 @@ int OutputMultipleStrings = 1;
// //
// Set up the per compile resources // Set up the per compile resources
// //
void GenerateResources(TBuiltInResource& resources) void GenerateResources(TBuiltInResource* resources)
{ {
resources.maxVertexAttribs = 8; ShInitBuiltInResource(resources);
resources.maxVertexUniformVectors = 128;
resources.maxVaryingVectors = 8; resources->MaxVertexAttribs = 8;
resources.maxVertexTextureImageUnits = 0; resources->MaxVertexUniformVectors = 128;
resources.maxCombinedTextureImageUnits = 8; resources->MaxVaryingVectors = 8;
resources.maxTextureImageUnits = 8; resources->MaxVertexTextureImageUnits = 0;
resources.maxFragmentUniformVectors = 16; resources->MaxCombinedTextureImageUnits = 8;
resources.maxDrawBuffers = 1; resources->MaxTextureImageUnits = 8;
resources->MaxFragmentUniformVectors = 16;
resources->MaxDrawBuffers = 1;
resources->OES_standard_derivatives = 0;
} }
int main(int argc, char* argv[]) int main(int argc, char* argv[])
...@@ -60,7 +64,7 @@ int main(int argc, char* argv[]) ...@@ -60,7 +64,7 @@ int main(int argc, char* argv[])
ShInitialize(); ShInitialize();
TBuiltInResource resources; TBuiltInResource resources;
GenerateResources(resources); GenerateResources(&resources);
argc--; argc--;
argv++; argv++;
......
...@@ -472,15 +472,15 @@ static TString BuiltInConstants(const TBuiltInResource &resources) ...@@ -472,15 +472,15 @@ static TString BuiltInConstants(const TBuiltInResource &resources)
{ {
TStringStream s; TStringStream s;
s << "const int gl_MaxVertexAttribs = " << resources.maxVertexAttribs << ";"; s << "const int gl_MaxVertexAttribs = " << resources.MaxVertexAttribs << ";";
s << "const int gl_MaxVertexUniformVectors = " << resources.maxVertexUniformVectors << ";"; s << "const int gl_MaxVertexUniformVectors = " << resources.MaxVertexUniformVectors << ";";
s << "const int gl_MaxVaryingVectors = " << resources.maxVaryingVectors << ";"; s << "const int gl_MaxVaryingVectors = " << resources.MaxVaryingVectors << ";";
s << "const int gl_MaxVertexTextureImageUnits = " << resources.maxVertexTextureImageUnits << ";"; s << "const int gl_MaxVertexTextureImageUnits = " << resources.MaxVertexTextureImageUnits << ";";
s << "const int gl_MaxCombinedTextureImageUnits = " << resources.maxCombinedTextureImageUnits << ";"; s << "const int gl_MaxCombinedTextureImageUnits = " << resources.MaxCombinedTextureImageUnits << ";";
s << "const int gl_MaxTextureImageUnits = " << resources.maxTextureImageUnits << ";"; s << "const int gl_MaxTextureImageUnits = " << resources.MaxTextureImageUnits << ";";
s << "const int gl_MaxFragmentUniformVectors = " << resources.maxFragmentUniformVectors << ";"; s << "const int gl_MaxFragmentUniformVectors = " << resources.MaxFragmentUniformVectors << ";";
s << "const int gl_MaxDrawBuffers = " << resources.maxDrawBuffers << ";"; s << "const int gl_MaxDrawBuffers = " << resources.MaxDrawBuffers << ";";
return s.str(); return s.str();
} }
...@@ -607,7 +607,7 @@ void IdentifyBuiltIns(EShLanguage language, EShSpec spec, const TBuiltInResource ...@@ -607,7 +607,7 @@ void IdentifyBuiltIns(EShLanguage language, EShSpec spec, const TBuiltInResource
case EShLangFragment: { case EShLangFragment: {
// Set up gl_FragData. The array size. // Set up gl_FragData. The array size.
TType fragData(EbtFloat, EbpMedium, EvqFragColor, 4, false, true); TType fragData(EbtFloat, EbpMedium, EvqFragColor, 4, false, true);
fragData.setArraySize(resources.maxDrawBuffers); fragData.setArraySize(resources.MaxDrawBuffers);
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData)); symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData));
} }
break; break;
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#ifndef _INITIALIZE_INCLUDED_ #ifndef _INITIALIZE_INCLUDED_
#define _INITIALIZE_INCLUDED_ #define _INITIALIZE_INCLUDED_
#include "GLSLANG/ResourceLimits.h"
#include "compiler/Common.h" #include "compiler/Common.h"
#include "compiler/ShHandle.h" #include "compiler/ShHandle.h"
#include "compiler/SymbolTable.h" #include "compiler/SymbolTable.h"
......
...@@ -97,9 +97,38 @@ int ShInitialize() ...@@ -97,9 +97,38 @@ int ShInitialize()
} }
// //
// Driver calls these to create and destroy compiler objects. // 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) ShHandle ShConstructCompiler(EShLanguage language, EShSpec spec, const TBuiltInResource* resources)
{ {
if (!InitThread()) if (!InitThread())
...@@ -131,17 +160,6 @@ void ShDestruct(ShHandle handle) ...@@ -131,17 +160,6 @@ void ShDestruct(ShHandle handle)
} }
// //
// Cleanup symbol tables
//
int ShFinalize()
{
if (!DetachProcess())
return 0;
return 1;
}
//
// Do an actual compile on the given strings. The result is left // Do an actual compile on the given strings. The result is left
// in the given compile object. // in the given compile object.
// //
......
...@@ -35,14 +35,15 @@ Shader::Shader(ResourceManager *manager, GLuint handle) : mHandle(handle), mReso ...@@ -35,14 +35,15 @@ Shader::Shader(ResourceManager *manager, GLuint handle) : mHandle(handle), mReso
if (result) if (result)
{ {
TBuiltInResource resources; TBuiltInResource resources;
resources.maxVertexAttribs = MAX_VERTEX_ATTRIBS; ShInitBuiltInResource(&resources);
resources.maxVertexUniformVectors = MAX_VERTEX_UNIFORM_VECTORS; resources.MaxVertexAttribs = MAX_VERTEX_ATTRIBS;
resources.maxVaryingVectors = MAX_VARYING_VECTORS; resources.MaxVertexUniformVectors = MAX_VERTEX_UNIFORM_VECTORS;
resources.maxVertexTextureImageUnits = MAX_VERTEX_TEXTURE_IMAGE_UNITS; resources.MaxVaryingVectors = MAX_VARYING_VECTORS;
resources.maxCombinedTextureImageUnits = MAX_COMBINED_TEXTURE_IMAGE_UNITS; resources.MaxVertexTextureImageUnits = MAX_VERTEX_TEXTURE_IMAGE_UNITS;
resources.maxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS; resources.MaxCombinedTextureImageUnits = MAX_COMBINED_TEXTURE_IMAGE_UNITS;
resources.maxFragmentUniformVectors = MAX_FRAGMENT_UNIFORM_VECTORS; resources.MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
resources.maxDrawBuffers = MAX_DRAW_BUFFERS; resources.MaxFragmentUniformVectors = MAX_FRAGMENT_UNIFORM_VECTORS;
resources.MaxDrawBuffers = MAX_DRAW_BUFFERS;
mFragmentCompiler = ShConstructCompiler(EShLangFragment, EShSpecGLES2, &resources); mFragmentCompiler = ShConstructCompiler(EShLangFragment, EShSpecGLES2, &resources);
mVertexCompiler = ShConstructCompiler(EShLangVertex, EShSpecGLES2, &resources); mVertexCompiler = ShConstructCompiler(EShLangVertex, EShSpecGLES2, &resources);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment