Commit f0338bbc by Maxime Grégoire

LibGL shader modification, LibGL texture1D and textureRectangle added

Change-Id: I89cc195563b8f57ebc807b3bf231bc71274cdf42 Reviewed-on: https://swiftshader-review.googlesource.com/3464Reviewed-by: 's avatarMaxime Grégoire <mgregoire@google.com> Tested-by: 's avatarMaxime Grégoire <mgregoire@google.com>
parent e2b31f2f
...@@ -129,10 +129,21 @@ enum TQualifier : unsigned char ...@@ -129,10 +129,21 @@ enum TQualifier : unsigned char
EvqInOut, EvqInOut,
EvqConstReadOnly, EvqConstReadOnly,
// built-ins read by fragment shader
EvqMultiTexCoord0,
EvqMultiTexCoord1,
EvqMultiTexCoord2,
EvqMultiTexCoord3,
EvqMultiTexCoord4,
EvqMultiTexCoord5,
EvqMultiTexCoord6,
EvqMultiTexCoord7,
// built-ins written by vertex shader // built-ins written by vertex shader
EvqPosition, EvqPosition,
EvqPointSize, EvqPointSize,
EvqInstanceID, EvqInstanceID,
EvqTexCoords,
// built-ins read by fragment shader // built-ins read by fragment shader
EvqFragCoord, EvqFragCoord,
...@@ -202,6 +213,15 @@ inline const char *getQualifierString(TQualifier qualifier) ...@@ -202,6 +213,15 @@ inline const char *getQualifierString(TQualifier qualifier)
case EvqPointSize: return "PointSize"; break; case EvqPointSize: return "PointSize"; break;
case EvqInstanceID: return "InstanceID"; break; case EvqInstanceID: return "InstanceID"; break;
case EvqFragCoord: return "FragCoord"; break; case EvqFragCoord: return "FragCoord"; break;
case EvqMultiTexCoord0: return "MultiTexCoord0"; break;
case EvqMultiTexCoord1: return "MultiTexCoord1"; break;
case EvqMultiTexCoord2: return "MultiTexCoord2"; break;
case EvqMultiTexCoord3: return "MultiTexCoord3"; break;
case EvqMultiTexCoord4: return "MultiTexCoord4"; break;
case EvqMultiTexCoord5: return "MultiTexCoord5"; break;
case EvqMultiTexCoord6: return "MultiTexCoord6"; break;
case EvqMultiTexCoord7: return "MultiTexCoord7"; break;
case EvqTexCoords: return "TexCoords"; break;
case EvqFrontFacing: return "FrontFacing"; break; case EvqFrontFacing: return "FrontFacing"; break;
case EvqFragColor: return "FragColor"; break; case EvqFragColor: return "FragColor"; break;
case EvqFragData: return "FragData"; break; case EvqFragData: return "FragData"; break;
......
...@@ -15,22 +15,22 @@ ...@@ -15,22 +15,22 @@
namespace namespace
{ {
class TScopedPoolAllocator { class TScopedPoolAllocator {
public: public:
TScopedPoolAllocator(TPoolAllocator* allocator, bool pushPop) TScopedPoolAllocator(TPoolAllocator* allocator, bool pushPop)
: mAllocator(allocator), mPushPopAllocator(pushPop) { : mAllocator(allocator), mPushPopAllocator(pushPop) {
if (mPushPopAllocator) mAllocator->push(); if(mPushPopAllocator) mAllocator->push();
SetGlobalPoolAllocator(mAllocator); SetGlobalPoolAllocator(mAllocator);
} }
~TScopedPoolAllocator() { ~TScopedPoolAllocator() {
SetGlobalPoolAllocator(NULL); SetGlobalPoolAllocator(NULL);
if (mPushPopAllocator) mAllocator->pop(); if(mPushPopAllocator) mAllocator->pop();
} }
private: private:
TPoolAllocator* mAllocator; TPoolAllocator* mAllocator;
bool mPushPopAllocator; bool mPushPopAllocator;
}; };
} // namespace } // namespace
// //
...@@ -45,6 +45,7 @@ ShBuiltInResources::ShBuiltInResources() ...@@ -45,6 +45,7 @@ ShBuiltInResources::ShBuiltInResources()
MaxVertexTextureImageUnits = 0; MaxVertexTextureImageUnits = 0;
MaxCombinedTextureImageUnits = 8; MaxCombinedTextureImageUnits = 8;
MaxTextureImageUnits = 8; MaxTextureImageUnits = 8;
MaxTextureCoords = 8;
MaxFragmentUniformVectors = 16; MaxFragmentUniformVectors = 16;
MaxDrawBuffers = 1; MaxDrawBuffers = 1;
MaxVertexOutputVectors = 16; MaxVertexOutputVectors = 16;
...@@ -81,7 +82,7 @@ bool TCompiler::Init(const ShBuiltInResources& resources) ...@@ -81,7 +82,7 @@ bool TCompiler::Init(const ShBuiltInResources& resources)
TScopedPoolAllocator scopedAlloc(&allocator, false); TScopedPoolAllocator scopedAlloc(&allocator, false);
// Generate built-in symbol table. // Generate built-in symbol table.
if (!InitBuiltInSymbolTable(resources)) if(!InitBuiltInSymbolTable(resources))
return false; return false;
InitExtensionBehavior(resources, extensionBehavior); InitExtensionBehavior(resources, extensionBehavior);
...@@ -95,13 +96,13 @@ bool TCompiler::compile(const char* const shaderStrings[], ...@@ -95,13 +96,13 @@ bool TCompiler::compile(const char* const shaderStrings[],
TScopedPoolAllocator scopedAlloc(&allocator, true); TScopedPoolAllocator scopedAlloc(&allocator, true);
clearResults(); clearResults();
if (numStrings == 0) if(numStrings == 0)
return true; return true;
// First string is path of source file if flag is set. The actual source follows. // First string is path of source file if flag is set. The actual source follows.
const char* sourcePath = NULL; const char* sourcePath = NULL;
int firstSource = 0; int firstSource = 0;
if (compileOptions & SH_SOURCE_PATH) if(compileOptions & SH_SOURCE_PATH)
{ {
sourcePath = shaderStrings[0]; sourcePath = shaderStrings[0];
++firstSource; ++firstSource;
...@@ -109,14 +110,14 @@ bool TCompiler::compile(const char* const shaderStrings[], ...@@ -109,14 +110,14 @@ bool TCompiler::compile(const char* const shaderStrings[],
TIntermediate intermediate(infoSink); TIntermediate intermediate(infoSink);
TParseContext parseContext(symbolTable, extensionBehavior, intermediate, TParseContext parseContext(symbolTable, extensionBehavior, intermediate,
shaderType, compileOptions, true, shaderType, compileOptions, false,
sourcePath, infoSink); sourcePath, infoSink);
SetGlobalParseContext(&parseContext); SetGlobalParseContext(&parseContext);
// We preserve symbols at the built-in level from compile-to-compile. // We preserve symbols at the built-in level from compile-to-compile.
// Start pushing the user-defined symbols at global level. // Start pushing the user-defined symbols at global level.
symbolTable.push(); symbolTable.push();
if (!symbolTable.atGlobalLevel()) if(!symbolTable.atGlobalLevel())
infoSink.info.message(EPrefixInternalError, "Wrong symbol table level"); infoSink.info.message(EPrefixInternalError, "Wrong symbol table level");
// Parse shader. // Parse shader.
...@@ -126,26 +127,26 @@ bool TCompiler::compile(const char* const shaderStrings[], ...@@ -126,26 +127,26 @@ bool TCompiler::compile(const char* const shaderStrings[],
shaderVersion = parseContext.getShaderVersion(); shaderVersion = parseContext.getShaderVersion();
if (success) { if(success) {
TIntermNode* root = parseContext.treeRoot; TIntermNode* root = parseContext.treeRoot;
success = intermediate.postProcess(root); success = intermediate.postProcess(root);
if (success) if(success)
success = validateCallDepth(root, infoSink); success = validateCallDepth(root, infoSink);
if (success && (compileOptions & SH_VALIDATE_LOOP_INDEXING)) if(success && (compileOptions & SH_VALIDATE_LOOP_INDEXING))
success = validateLimitations(root); success = validateLimitations(root);
if (success && (compileOptions & SH_INTERMEDIATE_TREE)) if(success && (compileOptions & SH_INTERMEDIATE_TREE))
intermediate.outputTree(root); intermediate.outputTree(root);
if (success && (compileOptions & SH_OBJECT_CODE)) if(success && (compileOptions & SH_OBJECT_CODE))
success = translate(root); success = translate(root);
} }
// Ensure symbol table is returned to the built-in level, // Ensure symbol table is returned to the built-in level,
// throwing away all but the built-ins. // throwing away all but the built-ins.
while (!symbolTable.atBuiltInLevel()) while(!symbolTable.atBuiltInLevel())
symbolTable.pop(); symbolTable.pop();
return success; return success;
...@@ -174,6 +175,7 @@ bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources) ...@@ -174,6 +175,7 @@ bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources)
{ {
case GL_FRAGMENT_SHADER: case GL_FRAGMENT_SHADER:
symbolTable.setDefaultPrecision(integer, EbpMedium); symbolTable.setDefaultPrecision(integer, EbpMedium);
symbolTable.setDefaultPrecision(floatingPoint, EbpHigh);
break; break;
case GL_VERTEX_SHADER: case GL_VERTEX_SHADER:
symbolTable.setDefaultPrecision(integer, EbpHigh); symbolTable.setDefaultPrecision(integer, EbpHigh);
......
...@@ -37,6 +37,7 @@ struct ShBuiltInResources ...@@ -37,6 +37,7 @@ struct ShBuiltInResources
int MaxVertexTextureImageUnits; int MaxVertexTextureImageUnits;
int MaxCombinedTextureImageUnits; int MaxCombinedTextureImageUnits;
int MaxTextureImageUnits; int MaxTextureImageUnits;
int MaxTextureCoords;
int MaxFragmentUniformVectors; int MaxFragmentUniformVectors;
int MaxDrawBuffers; int MaxDrawBuffers;
int MaxVertexOutputVectors; int MaxVertexOutputVectors;
......
...@@ -123,6 +123,7 @@ void InsertBuiltInFunctions(GLenum type, const ShBuiltInResources &resources, TS ...@@ -123,6 +123,7 @@ void InsertBuiltInFunctions(GLenum type, const ShBuiltInResources &resources, TS
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpFaceForward, genType, "faceforward", genType, genType, genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpFaceForward, genType, "faceforward", genType, genType, genType);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpReflect, genType, "reflect", genType, genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpReflect, genType, "reflect", genType, genType);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpRefract, genType, "refract", genType, genType, float1); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpRefract, genType, "refract", genType, genType, float1);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpFtransform, float4, "ftransform", 0);
TType *mat2 = new TType(EbtFloat, 2, 2); TType *mat2 = new TType(EbtFloat, 2, 2);
TType *mat2x3 = new TType(EbtFloat, 2, 3); TType *mat2x3 = new TType(EbtFloat, 2, 3);
...@@ -243,7 +244,7 @@ void InsertBuiltInFunctions(GLenum type, const ShBuiltInResources &resources, TS ...@@ -243,7 +244,7 @@ void InsertBuiltInFunctions(GLenum type, const ShBuiltInResources &resources, TS
{ {
symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpDFdx, "GL_OES_standard_derivatives", genType, "dFdx", genType); symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpDFdx, "GL_OES_standard_derivatives", genType, "dFdx", genType);
symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpDFdy, "GL_OES_standard_derivatives", genType, "dFdy", genType); symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpDFdy, "GL_OES_standard_derivatives", genType, "dFdy", genType);
symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpFwidth,"GL_OES_standard_derivatives", genType, "fwidth", genType); symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpFwidth, "GL_OES_standard_derivatives", genType, "fwidth", genType);
} }
} }
...@@ -293,9 +294,9 @@ void InsertBuiltInFunctions(GLenum type, const ShBuiltInResources &resources, TS ...@@ -293,9 +294,9 @@ void InsertBuiltInFunctions(GLenum type, const ShBuiltInResources &resources, TS
// Depth range in window coordinates // Depth range in window coordinates
// //
TTypeList *members = NewPoolTTypeList(); TTypeList *members = NewPoolTTypeList();
TTypeLine near = {new TType(EbtFloat, EbpHigh, EvqGlobal, 1), 0}; TTypeLine near = { new TType(EbtFloat, EbpHigh, EvqGlobal, 1), 0 };
TTypeLine far = {new TType(EbtFloat, EbpHigh, EvqGlobal, 1), 0}; TTypeLine far = { new TType(EbtFloat, EbpHigh, EvqGlobal, 1), 0 };
TTypeLine diff = {new TType(EbtFloat, EbpHigh, EvqGlobal, 1), 0}; TTypeLine diff = { new TType(EbtFloat, EbpHigh, EvqGlobal, 1), 0 };
near.type->setFieldName("near"); near.type->setFieldName("near");
far.type->setFieldName("far"); far.type->setFieldName("far");
diff.type->setFieldName("diff"); diff.type->setFieldName("diff");
...@@ -317,6 +318,7 @@ void InsertBuiltInFunctions(GLenum type, const ShBuiltInResources &resources, TS ...@@ -317,6 +318,7 @@ void InsertBuiltInFunctions(GLenum type, const ShBuiltInResources &resources, TS
symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxCombinedTextureImageUnits", resources.MaxCombinedTextureImageUnits); symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxCombinedTextureImageUnits", resources.MaxCombinedTextureImageUnits);
symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxTextureImageUnits", resources.MaxTextureImageUnits); symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxTextureImageUnits", resources.MaxTextureImageUnits);
symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxFragmentUniformVectors", resources.MaxFragmentUniformVectors); symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxFragmentUniformVectors", resources.MaxFragmentUniformVectors);
symbolTable.insertConstInt(ESSL1_BUILTINS, "gl_MaxTextureCoords", resources.MaxTextureCoords);
symbolTable.insertConstInt(ESSL1_BUILTINS, "gl_MaxVaryingVectors", resources.MaxVaryingVectors); symbolTable.insertConstInt(ESSL1_BUILTINS, "gl_MaxVaryingVectors", resources.MaxVaryingVectors);
symbolTable.insertConstInt(ESSL1_BUILTINS, "gl_MaxDrawBuffers", resources.MaxDrawBuffers); symbolTable.insertConstInt(ESSL1_BUILTINS, "gl_MaxDrawBuffers", resources.MaxDrawBuffers);
symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxVertexOutputVectors", resources.MaxVertexOutputVectors); symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxVertexOutputVectors", resources.MaxVertexOutputVectors);
...@@ -343,13 +345,26 @@ void IdentifyBuiltIns(GLenum shaderType, ...@@ -343,13 +345,26 @@ void IdentifyBuiltIns(GLenum shaderType,
symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqFragData, 4))); symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqFragData, 4)));
break; break;
case GL_VERTEX_SHADER: case GL_VERTEX_SHADER:
symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_Position"), TType(EbtFloat, EbpHigh, EvqPosition, 4))); symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_MultiTexCoord0"), TType(EbtFloat, EbpMedium, EvqMultiTexCoord0, 4)));
symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_MultiTexCoord1"), TType(EbtFloat, EbpMedium, EvqMultiTexCoord1, 4)));
symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_MultiTexCoord2"), TType(EbtFloat, EbpMedium, EvqMultiTexCoord2, 4)));
symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_MultiTexCoord3"), TType(EbtFloat, EbpMedium, EvqMultiTexCoord3, 4)));
symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_MultiTexCoord4"), TType(EbtFloat, EbpMedium, EvqMultiTexCoord4, 4)));
symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_MultiTexCoord5"), TType(EbtFloat, EbpMedium, EvqMultiTexCoord5, 4)));
symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_MultiTexCoord6"), TType(EbtFloat, EbpMedium, EvqMultiTexCoord6, 4)));
symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_MultiTexCoord7"), TType(EbtFloat, EbpMedium, EvqMultiTexCoord7, 4)));
symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_Position"), TType(EbtFloat, EbpMedium, EvqPosition, 4)));
symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_PointSize"), TType(EbtFloat, EbpMedium, EvqPointSize, 1))); symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_PointSize"), TType(EbtFloat, EbpMedium, EvqPointSize, 1)));
symbolTable.insert(ESSL3_BUILTINS, *new TVariable(NewPoolTString("gl_InstanceID"), TType(EbtInt, EbpHigh, EvqInstanceID, 1))); symbolTable.insert(ESSL3_BUILTINS, *new TVariable(NewPoolTString("gl_InstanceID"), TType(EbtInt, EbpHigh, EvqInstanceID, 1)));
break; break;
default: assert(false && "Language not supported"); default: assert(false && "Language not supported");
} }
// Set up gl_TexCoord
TType texCoord(EbtFloat, EbpMedium, EvqTexCoords, 4, 1, true);
texCoord.setArraySize(resources.MaxTextureCoords);
symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_TexCoord"), texCoord));
// Finally add resource-specific variables. // Finally add resource-specific variables.
switch(shaderType) switch(shaderType)
{ {
...@@ -361,6 +376,7 @@ void IdentifyBuiltIns(GLenum shaderType, ...@@ -361,6 +376,7 @@ void IdentifyBuiltIns(GLenum shaderType,
symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragData"), fragData)); symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragData"), fragData));
} }
break; break;
case GL_VERTEX_SHADER: break;
default: break; default: break;
} }
} }
......
...@@ -652,6 +652,12 @@ namespace glsl ...@@ -652,6 +652,12 @@ namespace glsl
case EOpFwidth: if(visit == PostVisit) emit(sw::Shader::OPCODE_FWIDTH, result, arg); break; case EOpFwidth: if(visit == PostVisit) emit(sw::Shader::OPCODE_FWIDTH, result, arg); break;
case EOpAny: if(visit == PostVisit) emit(sw::Shader::OPCODE_ANY, result, arg); break; case EOpAny: if(visit == PostVisit) emit(sw::Shader::OPCODE_ANY, result, arg); break;
case EOpAll: if(visit == PostVisit) emit(sw::Shader::OPCODE_ALL, result, arg); break; case EOpAll: if(visit == PostVisit) emit(sw::Shader::OPCODE_ALL, result, arg); break;
case EOpFtransform:
if(visit == PostVisit)
{
emit(sw::Shader::OPCODE_NOP, result, arg);
}
break;
case EOpTranspose: case EOpTranspose:
if(visit == PostVisit) if(visit == PostVisit)
{ {
...@@ -1078,6 +1084,7 @@ namespace glsl ...@@ -1078,6 +1084,7 @@ namespace glsl
case EOpFaceForward: if(visit == PostVisit) emit(sw::Shader::OPCODE_FORWARD(dim(arg[0])), result, arg[0], arg[1], arg[2]); break; case EOpFaceForward: if(visit == PostVisit) emit(sw::Shader::OPCODE_FORWARD(dim(arg[0])), result, arg[0], arg[1], arg[2]); break;
case EOpReflect: if(visit == PostVisit) emit(sw::Shader::OPCODE_REFLECT(dim(arg[0])), result, arg[0], arg[1]); break; case EOpReflect: if(visit == PostVisit) emit(sw::Shader::OPCODE_REFLECT(dim(arg[0])), result, arg[0], arg[1]); break;
case EOpRefract: if(visit == PostVisit) emit(sw::Shader::OPCODE_REFRACT(dim(arg[0])), result, arg[0], arg[1], arg[2]); break; case EOpRefract: if(visit == PostVisit) emit(sw::Shader::OPCODE_REFRACT(dim(arg[0])), result, arg[0], arg[1], arg[2]); break;
case EOpFtransform: break;
case EOpMul: case EOpMul:
if(visit == PostVisit) if(visit == PostVisit)
{ {
...@@ -1870,6 +1877,15 @@ namespace glsl ...@@ -1870,6 +1877,15 @@ namespace glsl
case EvqFragCoord: return sw::Shader::PARAMETER_MISCTYPE; case EvqFragCoord: return sw::Shader::PARAMETER_MISCTYPE;
case EvqFrontFacing: return sw::Shader::PARAMETER_MISCTYPE; case EvqFrontFacing: return sw::Shader::PARAMETER_MISCTYPE;
case EvqPointCoord: return sw::Shader::PARAMETER_INPUT; case EvqPointCoord: return sw::Shader::PARAMETER_INPUT;
case EvqMultiTexCoord0: return sw::Shader::PARAMETER_INPUT;
case EvqMultiTexCoord1: return sw::Shader::PARAMETER_INPUT;
case EvqMultiTexCoord2: return sw::Shader::PARAMETER_INPUT;
case EvqMultiTexCoord3: return sw::Shader::PARAMETER_INPUT;
case EvqMultiTexCoord4: return sw::Shader::PARAMETER_INPUT;
case EvqMultiTexCoord5: return sw::Shader::PARAMETER_INPUT;
case EvqMultiTexCoord6: return sw::Shader::PARAMETER_INPUT;
case EvqMultiTexCoord7: return sw::Shader::PARAMETER_INPUT;
case EvqTexCoords: return sw::Shader::PARAMETER_TEXTURE;
case EvqFragColor: return sw::Shader::PARAMETER_COLOROUT; case EvqFragColor: return sw::Shader::PARAMETER_COLOROUT;
case EvqFragData: return sw::Shader::PARAMETER_COLOROUT; case EvqFragData: return sw::Shader::PARAMETER_COLOROUT;
default: UNREACHABLE(); default: UNREACHABLE();
...@@ -1903,6 +1919,15 @@ namespace glsl ...@@ -1903,6 +1919,15 @@ namespace glsl
case EvqPosition: return varyingRegister(operand); case EvqPosition: return varyingRegister(operand);
case EvqPointSize: return varyingRegister(operand); case EvqPointSize: return varyingRegister(operand);
case EvqInstanceID: vertexShader->instanceIdDeclared = true; return 0; case EvqInstanceID: vertexShader->instanceIdDeclared = true; return 0;
case EvqMultiTexCoord0: return 0; //UNIMPLEMENTED();
case EvqMultiTexCoord1: return 0; //UNIMPLEMENTED();
case EvqMultiTexCoord2: return 0; //UNIMPLEMENTED();
case EvqMultiTexCoord3: return 0; //UNIMPLEMENTED();
case EvqMultiTexCoord4: return 0; //UNIMPLEMENTED();
case EvqMultiTexCoord5: return 0; //UNIMPLEMENTED();
case EvqMultiTexCoord6: return 0; //UNIMPLEMENTED();
case EvqMultiTexCoord7: return 0; //UNIMPLEMENTED();
case EvqTexCoords: return 0;
case EvqFragCoord: pixelShader->vPosDeclared = true; return 0; case EvqFragCoord: pixelShader->vPosDeclared = true; return 0;
case EvqFrontFacing: pixelShader->vFaceDeclared = true; return 1; case EvqFrontFacing: pixelShader->vFaceDeclared = true; return 1;
case EvqPointCoord: return varyingRegister(operand); case EvqPointCoord: return varyingRegister(operand);
......
...@@ -320,6 +320,14 @@ bool TParseContext::lValueErrorCheck(int line, const char* op, TIntermTyped* nod ...@@ -320,6 +320,14 @@ bool TParseContext::lValueErrorCheck(int line, const char* op, TIntermTyped* nod
case EvqCentroidIn: case EvqCentroidIn:
case EvqVaryingIn: message = "can't modify a varying"; break; case EvqVaryingIn: message = "can't modify a varying"; break;
case EvqInput: message = "can't modify an input"; break; case EvqInput: message = "can't modify an input"; break;
case EvqMultiTexCoord0: message = "can't modify gl_MultiTexCoord0"; break;
case EvqMultiTexCoord1: message = "can't modify gl_MultiTexCoord1"; break;
case EvqMultiTexCoord2: message = "can't modify gl_MultiTexCoord2"; break;
case EvqMultiTexCoord3: message = "can't modify gl_MultiTexCoord3"; break;
case EvqMultiTexCoord4: message = "can't modify gl_MultiTexCoord4"; break;
case EvqMultiTexCoord5: message = "can't modify gl_MultiTexCoord5"; break;
case EvqMultiTexCoord6: message = "can't modify gl_MultiTexCoord6"; break;
case EvqMultiTexCoord7: message = "can't modify gl_MultiTexCoord7"; break;
case EvqFragCoord: message = "can't modify gl_FragCoord"; break; case EvqFragCoord: message = "can't modify gl_FragCoord"; break;
case EvqFrontFacing: message = "can't modify gl_FrontFacing"; break; case EvqFrontFacing: message = "can't modify gl_FrontFacing"; break;
case EvqPointCoord: message = "can't modify gl_PointCoord"; break; case EvqPointCoord: message = "can't modify gl_PointCoord"; break;
......
...@@ -346,28 +346,28 @@ public: ...@@ -346,28 +346,28 @@ public:
void insertBuiltIn(ESymbolLevel level, TOperator op, const char *ext, TType *rvalue, const char *name, TType *ptype1, TType *ptype2 = 0, TType *ptype3 = 0, TType *ptype4 = 0) void insertBuiltIn(ESymbolLevel level, TOperator op, const char *ext, TType *rvalue, const char *name, TType *ptype1, TType *ptype2 = 0, TType *ptype3 = 0, TType *ptype4 = 0)
{ {
if(ptype1->getBasicType() == EbtGSampler2D) if(ptype1 && ptype1->getBasicType() == EbtGSampler2D)
{ {
bool gvec4 = (rvalue->getBasicType() == EbtGVec4); bool gvec4 = (rvalue->getBasicType() == EbtGVec4);
insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSampler2D), ptype2, ptype3, ptype4); insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSampler2D), ptype2, ptype3, ptype4);
insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISampler2D), ptype2, ptype3, ptype4); insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISampler2D), ptype2, ptype3, ptype4);
insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSampler2D), ptype2, ptype3, ptype4); insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSampler2D), ptype2, ptype3, ptype4);
} }
else if(ptype1->getBasicType() == EbtGSampler3D) else if(ptype1 && ptype1->getBasicType() == EbtGSampler3D)
{ {
bool gvec4 = (rvalue->getBasicType() == EbtGVec4); bool gvec4 = (rvalue->getBasicType() == EbtGVec4);
insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSampler3D), ptype2, ptype3, ptype4); insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSampler3D), ptype2, ptype3, ptype4);
insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISampler3D), ptype2, ptype3, ptype4); insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISampler3D), ptype2, ptype3, ptype4);
insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSampler3D), ptype2, ptype3, ptype4); insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSampler3D), ptype2, ptype3, ptype4);
} }
else if(ptype1->getBasicType() == EbtGSamplerCube) else if(ptype1 && ptype1->getBasicType() == EbtGSamplerCube)
{ {
bool gvec4 = (rvalue->getBasicType() == EbtGVec4); bool gvec4 = (rvalue->getBasicType() == EbtGVec4);
insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSamplerCube), ptype2, ptype3, ptype4); insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSamplerCube), ptype2, ptype3, ptype4);
insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISamplerCube), ptype2, ptype3, ptype4); insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISamplerCube), ptype2, ptype3, ptype4);
insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSamplerCube), ptype2, ptype3, ptype4); insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSamplerCube), ptype2, ptype3, ptype4);
} }
else if(ptype1->getBasicType() == EbtGSampler2DArray) else if(ptype1 && ptype1->getBasicType() == EbtGSampler2DArray)
{ {
bool gvec4 = (rvalue->getBasicType() == EbtGVec4); bool gvec4 = (rvalue->getBasicType() == EbtGVec4);
insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSampler2DArray), ptype2, ptype3, ptype4); insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSampler2DArray), ptype2, ptype3, ptype4);
...@@ -393,8 +393,11 @@ public: ...@@ -393,8 +393,11 @@ public:
{ {
TFunction *function = new TFunction(NewPoolTString(name), *rvalue, op, ext); TFunction *function = new TFunction(NewPoolTString(name), *rvalue, op, ext);
TParameter param1 = {0, ptype1}; if(ptype1)
{
TParameter param1 = { 0, ptype1 };
function->addParameter(param1); function->addParameter(param1);
}
if(ptype2) if(ptype2)
{ {
......
...@@ -298,6 +298,7 @@ bool TOutputTraverser::visitAggregate(Visit visit, TIntermAggregate* node) ...@@ -298,6 +298,7 @@ bool TOutputTraverser::visitAggregate(Visit visit, TIntermAggregate* node)
case EOpFaceForward: out << "face-forward"; break; case EOpFaceForward: out << "face-forward"; break;
case EOpReflect: out << "reflect"; break; case EOpReflect: out << "reflect"; break;
case EOpRefract: out << "refract"; break; case EOpRefract: out << "refract"; break;
case EOpFtransform: out << "ftransform"; break;
case EOpMul: out << "component-wise multiply"; break; case EOpMul: out << "component-wise multiply"; break;
case EOpOuterProduct: out << "outer product"; break; case EOpOuterProduct: out << "outer product"; break;
......
...@@ -155,6 +155,7 @@ enum TOperator { ...@@ -155,6 +155,7 @@ enum TOperator {
EOpFaceForward, EOpFaceForward,
EOpReflect, EOpReflect,
EOpRefract, EOpRefract,
EOpFtransform,
EOpDFdx, // Fragment only, OES_standard_derivatives extension EOpDFdx, // Fragment only, OES_standard_derivatives extension
EOpDFdy, // Fragment only, OES_standard_derivatives extension EOpDFdy, // Fragment only, OES_standard_derivatives extension
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <map> #include <map>
#include <string> #include <string>
#include <list> #include <list>
#include <stack>
namespace gl namespace gl
{ {
...@@ -293,6 +294,7 @@ class Shader; ...@@ -293,6 +294,7 @@ class Shader;
class Program; class Program;
class Texture; class Texture;
class Texture2D; class Texture2D;
class Texture1D;
class TextureCubeMap; class TextureCubeMap;
class Framebuffer; class Framebuffer;
class Renderbuffer; class Renderbuffer;
...@@ -309,12 +311,15 @@ class Query; ...@@ -309,12 +311,15 @@ class Query;
enum enum
{ {
MAX_VERTEX_ATTRIBS = 9, MAX_TEXTURE_COORDS = 8,
MAX_CLIENT_ATTRIB_STACK_DEPTH = 16,
MAX_TEXTURE_STACK_DEPTH = 10,
MAX_VERTEX_ATTRIBS = 16,
MAX_UNIFORM_VECTORS = 256, // Device limit MAX_UNIFORM_VECTORS = 256, // Device limit
MAX_VERTEX_UNIFORM_VECTORS = 256 - 3, // Reserve space for gl_DepthRange MAX_VERTEX_UNIFORM_VECTORS = 256 - 3, // Reserve space for gl_DepthRange
MAX_VARYING_VECTORS = 10, MAX_VARYING_VECTORS = 10,
MAX_TEXTURE_IMAGE_UNITS = 2, MAX_TEXTURE_IMAGE_UNITS = 16,
MAX_VERTEX_TEXTURE_IMAGE_UNITS = 1, MAX_VERTEX_TEXTURE_IMAGE_UNITS = 4,
MAX_COMBINED_TEXTURE_IMAGE_UNITS = MAX_TEXTURE_IMAGE_UNITS + MAX_VERTEX_TEXTURE_IMAGE_UNITS, MAX_COMBINED_TEXTURE_IMAGE_UNITS = MAX_TEXTURE_IMAGE_UNITS + MAX_VERTEX_TEXTURE_IMAGE_UNITS,
MAX_FRAGMENT_UNIFORM_VECTORS = 224 - 3, // Reserve space for gl_DepthRange MAX_FRAGMENT_UNIFORM_VECTORS = 224 - 3, // Reserve space for gl_DepthRange
MAX_DRAW_BUFFERS = 1, MAX_DRAW_BUFFERS = 1,
...@@ -490,6 +495,29 @@ struct State ...@@ -490,6 +495,29 @@ struct State
GLint unpackAlignment; GLint unpackAlignment;
GLint packAlignment; GLint packAlignment;
bool unpackSwapBytes;
bool unpackLsbFirst;
GLint unpackRowLength;
GLint unpackSkipRows;
GLint unpackSkipPixels;
GLint unpackSkipImages;
GLint unpackImageHeight;
GLenum textureEnvMode;
};
struct ClientAttributes
{
GLint unpackAlignment;
GLint packAlignment;
bool unpackSwapBytes;
bool unpackLsbFirst;
GLint unpackRowLength;
GLint unpackSkipRows;
GLint unpackSkipPixels;
GLint unpackSkipImages;
GLint unpackImageHeight;
GLbitfield mask;
}; };
class Context class Context
...@@ -583,6 +611,20 @@ public: ...@@ -583,6 +611,20 @@ public:
void setPackAlignment(GLint alignment); void setPackAlignment(GLint alignment);
GLint getPackAlignment() const; GLint getPackAlignment() const;
void setUnpackSwapBytes(bool swapBytes);
bool getUnpackSwapBytes() const;
void setUnpackLsbFirst(bool length);
bool getUnpackLsbFirst() const;
void setUnpackRowLength(GLint length);
GLint getUnpackRowLength() const;
void setUnpackSkipRows(GLint skipRows);
GLint getUnpackSkipRows() const;
void setUnpackSkipPixels(GLint skipRows);
GLint getUnpackSkipPixels() const;
void setUnpackSkipImages(GLint skipImage);
GLint getUnpackSkipImages() const;
void setUnpackImageHeight(GLint imageHeight);
GLint getUnpackImageHeight() const;
// These create and destroy methods are merely pass-throughs to // These create and destroy methods are merely pass-throughs to
// ResourceManager, which owns these object types // ResourceManager, which owns these object types
...@@ -612,6 +654,7 @@ public: ...@@ -612,6 +654,7 @@ public:
void bindArrayBuffer(GLuint buffer); void bindArrayBuffer(GLuint buffer);
void bindElementArrayBuffer(GLuint buffer); void bindElementArrayBuffer(GLuint buffer);
void bindTexture1D(GLuint texture);
void bindTexture2D(GLuint texture); void bindTexture2D(GLuint texture);
void bindTextureCubeMap(GLuint texture); void bindTextureCubeMap(GLuint texture);
void bindReadFramebuffer(GLuint framebuffer); void bindReadFramebuffer(GLuint framebuffer);
...@@ -643,6 +686,7 @@ public: ...@@ -643,6 +686,7 @@ public:
Texture2D *getTexture2D(GLenum target); Texture2D *getTexture2D(GLenum target);
TextureCubeMap *getTextureCubeMap(); TextureCubeMap *getTextureCubeMap();
Texture *getSamplerTexture(unsigned int sampler, TextureType type); Texture *getSamplerTexture(unsigned int sampler, TextureType type);
Texture1D *getTexture1D();
Framebuffer *getReadFramebuffer(); Framebuffer *getReadFramebuffer();
Framebuffer *getDrawFramebuffer(); Framebuffer *getDrawFramebuffer();
...@@ -659,6 +703,9 @@ public: ...@@ -659,6 +703,9 @@ public:
void finish(); void finish();
void flush(); void flush();
void setTextureEnvMode(GLenum texEnvMode);
GLenum getTextureEnvMode();
void recordInvalidEnum(); void recordInvalidEnum();
void recordInvalidValue(); void recordInvalidValue();
void recordInvalidOperation(); void recordInvalidOperation();
...@@ -685,6 +732,9 @@ public: ...@@ -685,6 +732,9 @@ public:
void frustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); void frustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
void ortho(double left, double right, double bottom, double top, double zNear, double zFar); // FIXME: GLdouble void ortho(double left, double right, double bottom, double top, double zNear, double zFar); // FIXME: GLdouble
void pushClientAttrib(GLbitfield mask);
void popClientAttrib();
void setLighting(bool enabled); void setLighting(bool enabled);
void setFog(bool enabled); void setFog(bool enabled);
void setAlphaTest(bool enabled); void setAlphaTest(bool enabled);
...@@ -693,6 +743,10 @@ public: ...@@ -693,6 +743,10 @@ public:
void setShadeModel(GLenum mode); void setShadeModel(GLenum mode);
void setLight(int index, bool enable); void setLight(int index, bool enable);
void setNormalizeNormals(bool enable); void setNormalizeNormals(bool enable);
void setRectangleTextureEnable(bool enable);
bool getRectangleTextureEnable();
void set1DTextureEnable(bool enable);
bool get1DTextureEnable();
GLuint genLists(GLsizei range); GLuint genLists(GLsizei range);
void newList(GLuint list, GLenum mode); void newList(GLuint list, GLenum mode);
...@@ -702,6 +756,7 @@ public: ...@@ -702,6 +756,7 @@ public:
GLuint getListIndex() {return listIndex;} GLuint getListIndex() {return listIndex;}
GLenum getListMode() {return listMode;} GLenum getListMode() {return listMode;}
void listCommand(Command *command); void listCommand(Command *command);
void shareDisplayListSpace(HGLRC hglrc);
void captureAttribs(); void captureAttribs();
void captureDrawArrays(GLenum mode, GLint first, GLsizei count); void captureDrawArrays(GLenum mode, GLint first, GLsizei count);
...@@ -742,6 +797,7 @@ private: ...@@ -742,6 +797,7 @@ private:
BindingPointer<Texture2D> mTexture2DZero; BindingPointer<Texture2D> mTexture2DZero;
BindingPointer<Texture2D> mProxyTexture2DZero; BindingPointer<Texture2D> mProxyTexture2DZero;
BindingPointer<TextureCubeMap> mTextureCubeMapZero; BindingPointer<TextureCubeMap> mTextureCubeMapZero;
BindingPointer<Texture1D> mTexture1DZero;
typedef std::map<GLint, Framebuffer*> FramebufferMap; typedef std::map<GLint, Framebuffer*> FramebufferMap;
FramebufferMap mFramebufferMap; FramebufferMap mFramebufferMap;
...@@ -789,12 +845,16 @@ private: ...@@ -789,12 +845,16 @@ private:
sw::MatrixStack projection; sw::MatrixStack projection;
sw::MatrixStack texture[8]; sw::MatrixStack texture[8];
std::stack<ClientAttributes> *clientAttribStack;
GLenum listMode; GLenum listMode;
//std::map<GLuint, GLuint> listMap; //std::map<GLuint, GLuint> listMap;
std::map<GLuint, DisplayList*> displayList; std::map<GLuint, DisplayList*> displayList;
DisplayList *list; DisplayList *list;
GLuint listIndex; GLuint listIndex;
GLuint firstFreeIndex; GLuint firstFreeIndex;
bool sharedList;
HGLRC sharedContextHandle;
GLenum clientTexture; GLenum clientTexture;
......
...@@ -157,6 +157,9 @@ namespace gl ...@@ -157,6 +157,9 @@ namespace gl
setSpecularMaterialSource(sw::MATERIAL_MATERIAL); setSpecularMaterialSource(sw::MATERIAL_MATERIAL);
setAmbientMaterialSource(sw::MATERIAL_COLOR1); setAmbientMaterialSource(sw::MATERIAL_COLOR1);
setEmissiveMaterialSource(sw::MATERIAL_MATERIAL); setEmissiveMaterialSource(sw::MATERIAL_MATERIAL);
rectangleTextureEnable = false;
oneDTextureEnable = false;
} }
Device::~Device() Device::~Device()
...@@ -441,6 +444,26 @@ namespace gl ...@@ -441,6 +444,26 @@ namespace gl
scissorEnable = enable; scissorEnable = enable;
} }
void Device::setRectangleTextureEnable(bool enable)
{
rectangleTextureEnable = enable;
}
bool Device::getRectangleTextureEnable()
{
return rectangleTextureEnable;
}
void Device::set1DTextureEnable(bool enable)
{
oneDTextureEnable = enable;
}
bool Device::get1DTextureEnable()
{
return oneDTextureEnable;
}
void Device::setRenderTarget(Image *renderTarget) void Device::setRenderTarget(Image *renderTarget)
{ {
if(renderTarget) if(renderTarget)
......
...@@ -59,6 +59,10 @@ namespace gl ...@@ -59,6 +59,10 @@ namespace gl
virtual void setPixelShader(sw::PixelShader *shader); virtual void setPixelShader(sw::PixelShader *shader);
virtual void setPixelShaderConstantF(unsigned int startRegister, const float *constantData, unsigned int count); virtual void setPixelShaderConstantF(unsigned int startRegister, const float *constantData, unsigned int count);
virtual void setScissorEnable(bool enable); virtual void setScissorEnable(bool enable);
virtual void setRectangleTextureEnable(bool enable);
virtual bool getRectangleTextureEnable();
virtual void set1DTextureEnable(bool enable);
virtual bool get1DTextureEnable();
virtual void setRenderTarget(Image *renderTarget); virtual void setRenderTarget(Image *renderTarget);
virtual void setScissorRect(const sw::Rect &rect); virtual void setScissorRect(const sw::Rect &rect);
virtual void setVertexShader(sw::VertexShader *shader); virtual void setVertexShader(sw::VertexShader *shader);
......
...@@ -323,7 +323,11 @@ void ResourceManager::checkTextureAllocation(GLuint texture, TextureType type) ...@@ -323,7 +323,11 @@ void ResourceManager::checkTextureAllocation(GLuint texture, TextureType type)
{ {
Texture *textureObject; Texture *textureObject;
if(type == TEXTURE_2D) if(type == TEXTURE_1D)
{
textureObject = new Texture1D(texture);
}
else if(type == TEXTURE_2D)
{ {
textureObject = new Texture2D(texture); textureObject = new Texture2D(texture);
} }
......
...@@ -37,6 +37,7 @@ enum TextureType ...@@ -37,6 +37,7 @@ enum TextureType
TEXTURE_2D, TEXTURE_2D,
PROXY_TEXTURE_2D, PROXY_TEXTURE_2D,
TEXTURE_CUBE, TEXTURE_CUBE,
TEXTURE_1D,
TEXTURE_TYPE_COUNT, TEXTURE_TYPE_COUNT,
TEXTURE_UNKNOWN TEXTURE_UNKNOWN
......
...@@ -167,6 +167,7 @@ TranslatorASM *Shader::createCompiler(GLenum shaderType) ...@@ -167,6 +167,7 @@ TranslatorASM *Shader::createCompiler(GLenum shaderType)
resources.MaxVertexTextureImageUnits = MAX_VERTEX_TEXTURE_IMAGE_UNITS; resources.MaxVertexTextureImageUnits = MAX_VERTEX_TEXTURE_IMAGE_UNITS;
resources.MaxCombinedTextureImageUnits = MAX_COMBINED_TEXTURE_IMAGE_UNITS; resources.MaxCombinedTextureImageUnits = MAX_COMBINED_TEXTURE_IMAGE_UNITS;
resources.MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS; resources.MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
resources.MaxTextureCoords = MAX_TEXTURE_COORDS;
resources.MaxFragmentUniformVectors = MAX_FRAGMENT_UNIFORM_VECTORS; resources.MaxFragmentUniformVectors = MAX_FRAGMENT_UNIFORM_VECTORS;
resources.MaxDrawBuffers = MAX_DRAW_BUFFERS; resources.MaxDrawBuffers = MAX_DRAW_BUFFERS;
resources.OES_standard_derivatives = 1; resources.OES_standard_derivatives = 1;
......
...@@ -168,11 +168,11 @@ GLfloat Texture::getMaxAnisotropy() const ...@@ -168,11 +168,11 @@ GLfloat Texture::getMaxAnisotropy() const
return mMaxAnisotropy; return mMaxAnisotropy;
} }
void Texture::setImage(GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, Image *image) void Texture::setImage(GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, Image *image, int xOffset)
{ {
if(pixels && image) if(pixels && image)
{ {
image->loadImageData(0, 0, 0, image->getWidth(), image->getHeight(), 1, format, type, unpackAlignment, pixels); image->loadImageData(xOffset/*0*/, 0, 0, image->getWidth(), image->getHeight(), 1, format, type, unpackAlignment, pixels);
} }
} }
...@@ -184,7 +184,7 @@ void Texture::setCompressedImage(GLsizei imageSize, const void *pixels, Image *i ...@@ -184,7 +184,7 @@ void Texture::setCompressedImage(GLsizei imageSize, const void *pixels, Image *i
} }
} }
void Texture::subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, Image *image) void Texture::subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, Image *image, bool is2DTexture)
{ {
if(!image) if(!image)
{ {
...@@ -201,7 +201,7 @@ void Texture::subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig ...@@ -201,7 +201,7 @@ void Texture::subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
if(format != image->getFormat()) if(format != image->getFormat() && is2DTexture)
{ {
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
...@@ -367,7 +367,7 @@ int Texture2D::getLevelCount() const ...@@ -367,7 +367,7 @@ int Texture2D::getLevelCount() const
return levels; return levels;
} }
void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels) void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, int xOffset)
{ {
if(image[level]) if(image[level])
{ {
...@@ -381,7 +381,7 @@ void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum form ...@@ -381,7 +381,7 @@ void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum form
return error(GL_OUT_OF_MEMORY); return error(GL_OUT_OF_MEMORY);
} }
Texture::setImage(format, type, unpackAlignment, pixels, image[level]); Texture::setImage(format, type, unpackAlignment, pixels, image[level], xOffset);
} }
void Texture2D::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels) void Texture2D::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels)
...@@ -1038,4 +1038,57 @@ Image *TextureCubeMap::getRenderTarget(GLenum target, unsigned int level) ...@@ -1038,4 +1038,57 @@ Image *TextureCubeMap::getRenderTarget(GLenum target, unsigned int level)
return image[face][level]; return image[face][level];
} }
Texture1D::Texture1D(GLuint name) : Texture2D(name)
{
}
Texture1D::~Texture1D()
{
}
GLenum Texture1D::getTarget() const
{
return GL_TEXTURE_1D;
}
GLenum Texture1D::getFormat(GLenum target, GLint level) const
{
ASSERT(target == GL_TEXTURE_1D);
return image[level] ? image[level]->getFormat() : 0;
}
GLenum Texture1D::getType(GLenum target, GLint level) const
{
ASSERT(target == GL_TEXTURE_1D);
return image[level] ? image[level]->getType() : 0;
}
GLsizei Texture1D::getWidth(GLenum target, GLint level) const
{
ASSERT(target == GL_TEXTURE_1D || target == GL_PROXY_TEXTURE_1D);
return image[level] ? image[level]->getWidth() : 0;
}
GLsizei Texture1D::getHeight(GLenum target, GLint level) const
{
ASSERT(target == GL_TEXTURE_1D || target == GL_PROXY_TEXTURE_1D);
return image[level] ? image[level]->getHeight() : 0;
}
sw::Format Texture1D::getInternalFormat(GLenum target, GLint level) const
{
ASSERT(target == GL_TEXTURE_1D || target == GL_PROXY_TEXTURE_1D);
return image[level] ? image[level]->getInternalFormat() : sw::FORMAT_NULL;
}
void Texture1D::subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
{
Texture::subImage(xoffset, yoffset, width, height, format, type, unpackAlignment, pixels, image[level], false);
}
bool Texture1D::isCompressed(GLenum target, GLint level) const
{
return IsCompressed(getFormat(target, level));
}
} }
...@@ -88,8 +88,8 @@ public: ...@@ -88,8 +88,8 @@ public:
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) = 0; virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) = 0;
protected: protected:
void setImage(GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, Image *image); void setImage(GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, Image *image, int xOffset = 0);
void subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, Image *image); void subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, Image *image, bool is2DTexture = true);
void setCompressedImage(GLsizei imageSize, const void *pixels, Image *image); void setCompressedImage(GLsizei imageSize, const void *pixels, Image *image);
void subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels, Image *image); void subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels, Image *image);
...@@ -126,7 +126,7 @@ public: ...@@ -126,7 +126,7 @@ public:
virtual sw::Format getInternalFormat(GLenum target, GLint level) const; virtual sw::Format getInternalFormat(GLenum target, GLint level) const;
virtual int getLevelCount() const; virtual int getLevelCount() const;
void setImage(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels); void setImage(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, int xOffset = 0);
void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels); void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
void subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels); void subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels); void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
...@@ -216,6 +216,21 @@ private: ...@@ -216,6 +216,21 @@ private:
unsigned int mFaceProxyRefs[6]; unsigned int mFaceProxyRefs[6];
}; };
class Texture1D : public Texture2D
{
public:
explicit Texture1D(GLuint name);
virtual ~Texture1D();
virtual GLenum getTarget() const;
virtual GLenum getFormat(GLenum target, GLint level) const;
virtual GLenum getType(GLenum target, GLint level) const;
virtual GLsizei getWidth(GLenum target, GLint level) const;
virtual GLsizei getHeight(GLenum target, GLint level) const;
virtual sw::Format getInternalFormat(GLenum target, GLint level) const;
virtual void subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
virtual bool isCompressed(GLenum target, GLint level) const;
};
} }
#endif // LIBGL_TEXTURE_H_ #endif // LIBGL_TEXTURE_H_
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -368,5 +368,6 @@ EXPORTS ...@@ -368,5 +368,6 @@ EXPORTS
wglUseFontBitmapsW @366 wglUseFontBitmapsW @366
wglUseFontOutlinesA @367 wglUseFontOutlinesA @367
wglUseFontOutlinesW @368 wglUseFontOutlinesW @368
wglCreateContextAttribsARB @369
Register Register
\ No newline at end of file
...@@ -309,7 +309,7 @@ namespace gl ...@@ -309,7 +309,7 @@ namespace gl
bool IsTextureTarget(GLenum target) bool IsTextureTarget(GLenum target)
{ {
return target == GL_TEXTURE_2D || IsCubemapTextureTarget(target); return target == GL_TEXTURE_1D || target == GL_TEXTURE_RECTANGLE || target == GL_TEXTURE_2D || IsCubemapTextureTarget(target);
} }
// Verify that format/type are one of the combinations from table 3.4. // Verify that format/type are one of the combinations from table 3.4.
...@@ -617,6 +617,59 @@ namespace es2sw ...@@ -617,6 +617,59 @@ namespace es2sw
} }
} }
void ConvertTextureOperations(GLenum texEnvMode, GLenum texFormat, sw::TextureStage::StageOperation *rgbOperation, sw::TextureStage::StageOperation *alphaOperation)
{
switch(texEnvMode)
{
case GL_MODULATE:
switch(texFormat)
{
case GL_LUMINANCE_ALPHA:
*rgbOperation = sw::TextureStage::STAGE_MODULATE;
*alphaOperation = sw::TextureStage::STAGE_MODULATE;
break;
case GL_RGB:
*rgbOperation = sw::TextureStage::STAGE_MODULATE;
*alphaOperation = sw::TextureStage::STAGE_SELECTARG2;
break;
case GL_RGBA:
*rgbOperation = sw::TextureStage::STAGE_MODULATE;
*alphaOperation = sw::TextureStage::STAGE_MODULATE;
break;
case GL_ALPHA:
case GL_LUMINANCE:
UNIMPLEMENTED();
// Default operations for compatibility
*rgbOperation = sw::TextureStage::STAGE_MODULATE;
*alphaOperation = sw::TextureStage::STAGE_MODULATE;
break;
default: UNREACHABLE();
}
break;
case GL_REPLACE:
*rgbOperation = sw::TextureStage::STAGE_SELECTARG1;
*alphaOperation = sw::TextureStage::STAGE_SELECTARG1;
break;
case GL_ADD:
*rgbOperation = sw::TextureStage::STAGE_ADD;
*alphaOperation = sw::TextureStage::STAGE_SELECTARG1;
break;
case GL_DECAL:
case GL_BLEND:
// Default operations for compatibility
*rgbOperation = sw::TextureStage::STAGE_MODULATE;
*alphaOperation = sw::TextureStage::STAGE_MODULATE;
UNIMPLEMENTED();
break;
default:
UNREACHABLE();
}
}
bool ConvertPrimitiveType(GLenum primitiveType, GLsizei elementCount, gl::PrimitiveType &swPrimitiveType, int &primitiveCount) bool ConvertPrimitiveType(GLenum primitiveType, GLsizei elementCount, gl::PrimitiveType &swPrimitiveType, int &primitiveCount)
{ {
switch(primitiveType) switch(primitiveType)
......
...@@ -69,6 +69,7 @@ namespace es2sw ...@@ -69,6 +69,7 @@ namespace es2sw
void ConvertMinFilter(GLenum texFilter, sw::FilterType *minFilter, sw::MipmapType *mipFilter, float maxAnisotropy); void ConvertMinFilter(GLenum texFilter, sw::FilterType *minFilter, sw::MipmapType *mipFilter, float maxAnisotropy);
bool ConvertPrimitiveType(GLenum primitiveType, GLsizei elementCount, gl::PrimitiveType &swPrimitiveType, int &primitiveCount); bool ConvertPrimitiveType(GLenum primitiveType, GLsizei elementCount, gl::PrimitiveType &swPrimitiveType, int &primitiveCount);
sw::Format ConvertRenderbufferFormat(GLenum format); sw::Format ConvertRenderbufferFormat(GLenum format);
void ConvertTextureOperations(GLenum texEnvMode, GLenum texFormat, sw::TextureStage::StageOperation *rgbOperation, sw::TextureStage::StageOperation *alphaOperation);
} }
namespace sw2es namespace sw2es
......
...@@ -284,6 +284,8 @@ namespace sw ...@@ -284,6 +284,8 @@ namespace sw
// Set fixed-function pixel pipeline states, return true when modified // Set fixed-function pixel pipeline states, return true when modified
bool setDepthBufferEnable(bool depthBufferEnable); bool setDepthBufferEnable(bool depthBufferEnable);
void setRectangleTextureEnable(bool rectangleTextureEnable);
bool setAlphaBlendEnable(bool alphaBlendEnable); bool setAlphaBlendEnable(bool alphaBlendEnable);
bool setSourceBlendFactor(BlendFactor sourceBlendFactor); bool setSourceBlendFactor(BlendFactor sourceBlendFactor);
bool setDestBlendFactor(BlendFactor destBlendFactor); bool setDestBlendFactor(BlendFactor destBlendFactor);
......
...@@ -213,6 +213,16 @@ namespace sw ...@@ -213,6 +213,16 @@ namespace sw
updateLighting = true; updateLighting = true;
} }
void VertexProcessor::setRectangleTextureEnable(bool enable)
{
rectangleTextureEnable = enable;
}
bool VertexProcessor::getRectangleTextureEnable()
{
return rectangleTextureEnable;
}
void VertexProcessor::setSpecularEnable(bool specularEnable) void VertexProcessor::setSpecularEnable(bool specularEnable)
{ {
context->setSpecularEnable(specularEnable); context->setSpecularEnable(specularEnable);
......
...@@ -196,6 +196,9 @@ namespace sw ...@@ -196,6 +196,9 @@ namespace sw
virtual void setLightEnable(unsigned int light, bool lightEnable); virtual void setLightEnable(unsigned int light, bool lightEnable);
virtual void setSpecularEnable(bool specularEnable); virtual void setSpecularEnable(bool specularEnable);
void setRectangleTextureEnable(bool enable);
bool getRectangleTextureEnable();
virtual void setGlobalAmbient(const Color<float> &globalAmbient); virtual void setGlobalAmbient(const Color<float> &globalAmbient);
virtual void setLightPosition(unsigned int light, const Point &lightPosition); virtual void setLightPosition(unsigned int light, const Point &lightPosition);
virtual void setLightViewPosition(unsigned int light, const Point &lightPosition); virtual void setLightViewPosition(unsigned int light, const Point &lightPosition);
...@@ -296,6 +299,8 @@ namespace sw ...@@ -296,6 +299,8 @@ namespace sw
bool updateBaseMatrix; bool updateBaseMatrix;
bool updateProjectionMatrix; bool updateProjectionMatrix;
bool updateLighting; bool updateLighting;
bool rectangleTextureEnable;
bool oneDTextureEnable;
}; };
} }
......
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