Commit e9c5e4f1 by Nicolas Capens Committed by Nicolas Capens

Implement GL_OES_EGL_image_external support.

BUG=14610416 Change-Id: I9ca6d1779c7b6f1b28d5d5665264815881ee01b5 Reviewed-on: https://swiftshader-review.googlesource.com/1071Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 434311cd
......@@ -42,6 +42,7 @@ enum TBasicType
EbtGuardSamplerBegin, // non type: see implementation of IsSampler()
EbtSampler2D,
EbtSamplerCube,
EbtSamplerExternalOES,
EbtGuardSamplerEnd, // non type: see implementation of IsSampler()
EbtStruct,
EbtAddress, // should be deprecated??
......@@ -52,14 +53,15 @@ inline const char* getBasicString(TBasicType t)
{
switch (t)
{
case EbtVoid: return "void"; break;
case EbtFloat: return "float"; break;
case EbtInt: return "int"; break;
case EbtBool: return "bool"; break;
case EbtSampler2D: return "sampler2D"; break;
case EbtSamplerCube: return "samplerCube"; break;
case EbtStruct: return "structure"; break;
default: return "unknown type";
case EbtVoid: return "void";
case EbtFloat: return "float";
case EbtInt: return "int";
case EbtBool: return "bool";
case EbtSampler2D: return "sampler2D";
case EbtSamplerCube: return "samplerCube";
case EbtSamplerExternalOES: return "samplerExternalOES";
case EbtStruct: return "structure";
default: return "unknown type";
}
}
......
......@@ -295,6 +295,15 @@ void InsertBuiltInFunctions(ShShaderType type, const ShBuiltInResources &resourc
symbolTable.insertBuiltIn(float4, "textureCubeLod", samplerCube, float3, float1);
}
TType *samplerExternalOES = new TType(EbtSamplerExternalOES, EbpUndefined, EvqGlobal, 1);
if(resources.OES_EGL_image_external)
{
symbolTable.insertBuiltIn(float4, "texture2D", samplerExternalOES, float2);
symbolTable.insertBuiltIn(float4, "texture2DProj", samplerExternalOES, float3);
symbolTable.insertBuiltIn(float4, "texture2DProj", samplerExternalOES, float4);
}
TTypeList *members = NewPoolTTypeList();
TTypeLine near = {new TType(EbtFloat, EbpHigh, EvqGlobal, 1), 0};
TTypeLine far = {new TType(EbtFloat, EbpHigh, EvqGlobal, 1), 0};
......
......@@ -420,12 +420,9 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
//
// Does the base type allow operation?
//
switch (node->getBasicType()) {
case EbtVoid:
case EbtSampler2D:
case EbtSamplerCube:
return 0;
default: break;
if (node->getBasicType() == EbtVoid || IsSampler(node->getBasicType()))
{
return 0;
}
//
......
......@@ -18,6 +18,7 @@
#define GL_APICALL
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
namespace sh
{
......@@ -2280,6 +2281,10 @@ namespace sh
{
return GL_SAMPLER_CUBE;
}
else if(type.getBasicType() == EbtSamplerExternalOES)
{
return GL_SAMPLER_EXTERNAL_OES;
}
else UNREACHABLE();
return GL_NONE;
......
......@@ -326,16 +326,13 @@ bool TParseContext::lValueErrorCheck(int line, const char* op, TIntermTyped* nod
//
// Type that can't be written to?
//
switch (node->getBasicType()) {
case EbtSampler2D:
case EbtSamplerCube:
if(IsSampler(node->getBasicType()))
{
message = "can't modify a sampler";
break;
case EbtVoid:
}
else if(node->getBasicType() == EbtVoid)
{
message = "can't modify void";
break;
default:
break;
}
}
......
......@@ -110,6 +110,7 @@ void ShInitBuiltInResources(ShBuiltInResources* resources)
// Extensions.
resources->OES_standard_derivatives = 0;
resources->OES_fragment_precision_high = 0;
resources->OES_EGL_image_external = 0;
resources->MaxCallStackDepth = UINT_MAX;
}
......
......@@ -52,6 +52,7 @@ void TType::buildMangledName(TString& mangledName)
case EbtBool: mangledName += 'b'; break;
case EbtSampler2D: mangledName += "s2"; break;
case EbtSamplerCube: mangledName += "sC"; break;
case EbtSamplerExternalOES: mangledName += "sE"; break;
case EbtStruct:
mangledName += "struct-";
if (typeName)
......
......@@ -63,6 +63,7 @@ static ShDataType getVariableDataType(const TType& type)
}
case EbtSampler2D: return SH_SAMPLER_2D;
case EbtSamplerCube: return SH_SAMPLER_CUBE;
case EbtSamplerExternalOES: return SH_SAMPLER_EXTERNAL_OES;
default: UNREACHABLE();
}
return SH_NONE;
......
......@@ -133,6 +133,7 @@ O [0-7]
"sampler2D" { context->lexAfterType = true; return SAMPLER2D; }
"samplerCube" { context->lexAfterType = true; return SAMPLERCUBE; }
"samplerExternalOES" { context->lexAfterType = true; return SAMPLER_EXTERNAL_OES; }
"struct" { context->lexAfterType = true; return(STRUCT); }
......
......@@ -113,7 +113,7 @@ extern void yyerror(TParseContext* context, const char* reason);
%token <lex> BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 VEC2 VEC3 VEC4
%token <lex> MATRIX2 MATRIX3 MATRIX4 IN_QUAL OUT_QUAL INOUT_QUAL UNIFORM VARYING
%token <lex> STRUCT VOID_TYPE WHILE
%token <lex> SAMPLER2D SAMPLERCUBE
%token <lex> SAMPLER2D SAMPLERCUBE SAMPLER_EXTERNAL_OES
%token <lex> IDENTIFIER TYPE_NAME FLOATCONSTANT INTCONSTANT BOOLCONSTANT
%token <lex> FIELD_SELECTION
......@@ -1657,6 +1657,15 @@ type_specifier_nonarray
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtSamplerCube, qual, $1.line);
}
| SAMPLER_EXTERNAL_OES {
if (!context->supportsExtension("GL_OES_EGL_image_external")) {
context->error($1.line, "unsupported type", "samplerExternalOES", "");
context->recover();
}
FRAG_VERT_ONLY("samplerExternalOES", $1.line);
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtSamplerExternalOES, qual, $1.line);
}
| struct_specifier {
FRAG_VERT_ONLY("struct", $1.line);
$$ = $1;
......
/* A Bison parser, made by GNU Bison 2.4.2. */
/* A Bison parser, made by GNU Bison 2.4.1. */
/* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software
Foundation, Inc.
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -78,57 +79,58 @@
WHILE = 295,
SAMPLER2D = 296,
SAMPLERCUBE = 297,
IDENTIFIER = 298,
TYPE_NAME = 299,
FLOATCONSTANT = 300,
INTCONSTANT = 301,
BOOLCONSTANT = 302,
FIELD_SELECTION = 303,
LEFT_OP = 304,
RIGHT_OP = 305,
INC_OP = 306,
DEC_OP = 307,
LE_OP = 308,
GE_OP = 309,
EQ_OP = 310,
NE_OP = 311,
AND_OP = 312,
OR_OP = 313,
XOR_OP = 314,
MUL_ASSIGN = 315,
DIV_ASSIGN = 316,
ADD_ASSIGN = 317,
MOD_ASSIGN = 318,
LEFT_ASSIGN = 319,
RIGHT_ASSIGN = 320,
AND_ASSIGN = 321,
XOR_ASSIGN = 322,
OR_ASSIGN = 323,
SUB_ASSIGN = 324,
LEFT_PAREN = 325,
RIGHT_PAREN = 326,
LEFT_BRACKET = 327,
RIGHT_BRACKET = 328,
LEFT_BRACE = 329,
RIGHT_BRACE = 330,
DOT = 331,
COMMA = 332,
COLON = 333,
EQUAL = 334,
SEMICOLON = 335,
BANG = 336,
DASH = 337,
TILDE = 338,
PLUS = 339,
STAR = 340,
SLASH = 341,
PERCENT = 342,
LEFT_ANGLE = 343,
RIGHT_ANGLE = 344,
VERTICAL_BAR = 345,
CARET = 346,
AMPERSAND = 347,
QUESTION = 348
SAMPLER_EXTERNAL_OES = 298,
IDENTIFIER = 299,
TYPE_NAME = 300,
FLOATCONSTANT = 301,
INTCONSTANT = 302,
BOOLCONSTANT = 303,
FIELD_SELECTION = 304,
LEFT_OP = 305,
RIGHT_OP = 306,
INC_OP = 307,
DEC_OP = 308,
LE_OP = 309,
GE_OP = 310,
EQ_OP = 311,
NE_OP = 312,
AND_OP = 313,
OR_OP = 314,
XOR_OP = 315,
MUL_ASSIGN = 316,
DIV_ASSIGN = 317,
ADD_ASSIGN = 318,
MOD_ASSIGN = 319,
LEFT_ASSIGN = 320,
RIGHT_ASSIGN = 321,
AND_ASSIGN = 322,
XOR_ASSIGN = 323,
OR_ASSIGN = 324,
SUB_ASSIGN = 325,
LEFT_PAREN = 326,
RIGHT_PAREN = 327,
LEFT_BRACKET = 328,
RIGHT_BRACKET = 329,
LEFT_BRACE = 330,
RIGHT_BRACE = 331,
DOT = 332,
COMMA = 333,
COLON = 334,
EQUAL = 335,
SEMICOLON = 336,
BANG = 337,
DASH = 338,
TILDE = 339,
PLUS = 340,
STAR = 341,
SLASH = 342,
PERCENT = 343,
LEFT_ANGLE = 344,
RIGHT_ANGLE = 345,
VERTICAL_BAR = 346,
CARET = 347,
AMPERSAND = 348,
QUESTION = 349
};
#endif
......
......@@ -53,7 +53,8 @@ typedef enum {
SH_FLOAT_MAT3 = 0x8B5B,
SH_FLOAT_MAT4 = 0x8B5C,
SH_SAMPLER_2D = 0x8B5E,
SH_SAMPLER_CUBE = 0x8B60
SH_SAMPLER_CUBE = 0x8B60,
SH_SAMPLER_EXTERNAL_OES = 0x8D66
} ShDataType;
typedef enum {
......@@ -108,6 +109,7 @@ typedef struct
// Set to 1 to enable the extension, else 0.
int OES_standard_derivatives;
int OES_fragment_precision_high;
int OES_EGL_image_external;
unsigned int MaxCallStackDepth;
} ShBuiltInResources;
......
......@@ -126,6 +126,7 @@ Context::Context(const egl::Config *config, const Context *shareContext) : mConf
mTexture2DZero.set(new Texture2D(0));
mTextureCubeMapZero.set(new TextureCubeMap(0));
mTextureExternalZero.set(new TextureExternal(0));
mState.activeSampler = 0;
bindArrayBuffer(0);
......@@ -206,6 +207,7 @@ Context::~Context()
mTexture2DZero.set(NULL);
mTextureCubeMapZero.set(NULL);
mTextureExternalZero.set(NULL);
delete mVertexDataManager;
delete mIndexDataManager;
......@@ -222,8 +224,6 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
mVertexDataManager = new VertexDataManager(this);
mIndexDataManager = new IndexDataManager();
initExtensionString();
mState.viewportX = 0;
mState.viewportY = 0;
mState.viewportWidth = surface->getWidth();
......@@ -929,6 +929,13 @@ void Context::bindTextureCubeMap(GLuint texture)
mState.samplerTexture[TEXTURE_CUBE][mState.activeSampler].set(getTexture(texture));
}
void Context::bindTextureExternal(GLuint texture)
{
mResourceManager->checkTextureAllocation(texture, TEXTURE_EXTERNAL);
mState.samplerTexture[TEXTURE_EXTERNAL][mState.activeSampler].set(getTexture(texture));
}
void Context::bindReadFramebuffer(GLuint framebuffer)
{
if(!getFramebuffer(framebuffer))
......@@ -1150,6 +1157,11 @@ TextureCubeMap *Context::getTextureCubeMap()
return static_cast<TextureCubeMap*>(getSamplerTexture(mState.activeSampler, TEXTURE_CUBE));
}
TextureExternal *Context::getTextureExternal()
{
return static_cast<TextureExternal*>(getSamplerTexture(mState.activeSampler, TEXTURE_EXTERNAL));
}
Texture *Context::getSamplerTexture(unsigned int sampler, TextureType type)
{
GLuint texid = mState.samplerTexture[type][sampler].id();
......@@ -1158,9 +1170,10 @@ Texture *Context::getSamplerTexture(unsigned int sampler, TextureType type)
{
switch (type)
{
default: UNREACHABLE();
case TEXTURE_2D: return mTexture2DZero.get();
case TEXTURE_CUBE: return mTextureCubeMapZero.get();
case TEXTURE_2D: return mTexture2DZero.get();
case TEXTURE_CUBE: return mTextureCubeMapZero.get();
case TEXTURE_EXTERNAL: return mTextureExternalZero.get();
default: UNREACHABLE();
}
}
......@@ -1457,6 +1470,17 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
*params = mState.samplerTexture[TEXTURE_CUBE][mState.activeSampler].id();
}
break;
case GL_TEXTURE_BINDING_EXTERNAL_OES:
{
if(mState.activeSampler < 0 || mState.activeSampler > MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1)
{
error(GL_INVALID_OPERATION);
return false;
}
*params = mState.samplerTexture[TEXTURE_EXTERNAL][mState.activeSampler].id();
}
break;
default:
return false;
}
......@@ -1546,6 +1570,7 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
case GL_TEXTURE_BINDING_2D:
case GL_TEXTURE_BINDING_CUBE_MAP:
case GL_TEXTURE_BINDING_EXTERNAL_OES:
{
*type = GL_INT;
*numParams = 1;
......@@ -2065,7 +2090,7 @@ void Context::applyTexture(sw::SamplerType type, int index, Texture *baseTexture
{
int levelCount = baseTexture->getLevelCount();
if(baseTexture->isTexture2D())
if(baseTexture->getTarget() == GL_TEXTURE_2D || baseTexture->getTarget() == GL_TEXTURE_EXTERNAL_OES)
{
Texture2D *texture = static_cast<Texture2D*>(baseTexture);
......@@ -2086,7 +2111,7 @@ void Context::applyTexture(sw::SamplerType type, int index, Texture *baseTexture
device->setTextureLevel(sampler, 0, mipmapLevel, surface, sw::TEXTURE_2D);
}
}
else if(baseTexture->isTextureCubeMap())
else if(baseTexture->getTarget() == GL_TEXTURE_CUBE_MAP)
{
for(int face = 0; face < 6; face++)
{
......@@ -2724,53 +2749,6 @@ void Context::setVertexAttrib(GLuint index, const GLfloat *values)
mVertexDataManager->dirtyCurrentValue(index);
}
void Context::initExtensionString()
{
// Keep list sorted in following order:
// OES extensions
// EXT extensions
// Vendor extensions
mExtensionString += "GL_OES_depth_texture ";
mExtensionString += "GL_OES_depth_texture_cube_map ";
mExtensionString += "GL_OES_element_index_uint ";
mExtensionString += "GL_OES_packed_depth_stencil ";
mExtensionString += "GL_OES_rgb8_rgba8 ";
mExtensionString += "GL_OES_standard_derivatives ";
mExtensionString += "GL_OES_texture_float ";
mExtensionString += "GL_OES_texture_float_linear ";
mExtensionString += "GL_OES_texture_half_float ";
mExtensionString += "GL_OES_texture_half_float_linear ";
mExtensionString += "GL_OES_texture_npot ";
mExtensionString += "GL_EXT_blend_minmax ";
mExtensionString += "GL_EXT_occlusion_query_boolean ";
mExtensionString += "GL_EXT_read_format_bgra ";
if(S3TC_SUPPORT)
{
mExtensionString += "GL_EXT_texture_compression_dxt1 ";
mExtensionString += "GL_ANGLE_texture_compression_dxt3 ";
mExtensionString += "GL_ANGLE_texture_compression_dxt5 ";
}
mExtensionString += "GL_EXT_texture_filter_anisotropic ";
mExtensionString += "GL_EXT_texture_format_BGRA8888 ";
mExtensionString += "GL_ANGLE_framebuffer_blit ";
mExtensionString += "GL_ANGLE_framebuffer_multisample ";
mExtensionString += "GL_NV_fence ";
std::string::size_type end = mExtensionString.find_last_not_of(' ');
if(end != std::string::npos)
{
mExtensionString.resize(end + 1);
}
}
const char *Context::getExtensionString() const
{
return mExtensionString.c_str();
}
void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask)
......
......@@ -48,6 +48,7 @@ class Program;
class Texture;
class Texture2D;
class TextureCubeMap;
class TextureExternal;
class Framebuffer;
class Renderbuffer;
class RenderbufferStorage;
......@@ -356,6 +357,7 @@ class Context
void bindElementArrayBuffer(GLuint buffer);
void bindTexture2D(GLuint texture);
void bindTextureCubeMap(GLuint texture);
void bindTextureExternal(GLuint texture);
void bindReadFramebuffer(GLuint framebuffer);
void bindDrawFramebuffer(GLuint framebuffer);
void bindRenderbuffer(GLuint renderbuffer);
......@@ -384,6 +386,7 @@ class Context
Program *getCurrentProgram();
Texture2D *getTexture2D();
TextureCubeMap *getTextureCubeMap();
TextureExternal *getTextureExternal();
Texture *getSamplerTexture(unsigned int sampler, TextureType type);
Framebuffer *getReadFramebuffer();
Framebuffer *getDrawFramebuffer();
......@@ -410,7 +413,6 @@ class Context
GLenum getError();
static int getSupportedMultiSampleDepth(sw::Format format, int requested);
const char *getExtensionString() const;
void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
......@@ -440,6 +442,7 @@ class Context
BindingPointer<Texture2D> mTexture2DZero;
BindingPointer<TextureCubeMap> mTextureCubeMapZero;
BindingPointer<TextureExternal> mTextureExternalZero;
typedef std::map<GLint, Framebuffer*> FramebufferMap;
FramebufferMap mFramebufferMap;
......@@ -453,9 +456,6 @@ class Context
QueryMap mQueryMap;
HandleAllocator mQueryHandleAllocator;
void initExtensionString();
std::string mExtensionString;
VertexDataManager *mVertexDataManager;
IndexDataManager *mIndexDataManager;
......
......@@ -590,7 +590,8 @@ namespace gl
if(targetUniform->type == GL_INT ||
targetUniform->type == GL_SAMPLER_2D ||
targetUniform->type == GL_SAMPLER_CUBE)
targetUniform->type == GL_SAMPLER_CUBE ||
targetUniform->type == GL_SAMPLER_EXTERNAL_OES)
{
memcpy(targetUniform->data + uniformIndex[location].element * sizeof(GLint),
v, sizeof(GLint) * count);
......@@ -923,6 +924,7 @@ namespace gl
case GL_FLOAT_MAT4: applyUniformMatrix4fv(location, size, f); break;
case GL_SAMPLER_2D:
case GL_SAMPLER_CUBE:
case GL_SAMPLER_EXTERNAL_OES:
case GL_INT: applyUniform1iv(location, size, i); break;
case GL_INT_VEC2: applyUniform2iv(location, size, i); break;
case GL_INT_VEC3: applyUniform3iv(location, size, i); break;
......@@ -1313,7 +1315,7 @@ namespace gl
bool Program::defineUniform(GLenum shader, GLenum type, GLenum precision, const std::string &name, unsigned int arraySize, int registerIndex)
{
if(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE)
if(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || type == GL_SAMPLER_EXTERNAL_OES)
{
int index = registerIndex;
......@@ -1733,8 +1735,9 @@ namespace gl
if(targetUniform->psRegisterIndex != -1)
{
if(targetUniform->type == GL_SAMPLER_2D ||
targetUniform->type == GL_SAMPLER_CUBE)
if(targetUniform->type == GL_SAMPLER_2D ||
targetUniform->type == GL_SAMPLER_CUBE ||
targetUniform->type == GL_SAMPLER_EXTERNAL_OES)
{
for(int i = 0; i < count; i++)
{
......@@ -1756,7 +1759,8 @@ namespace gl
if(targetUniform->vsRegisterIndex != -1)
{
if(targetUniform->type == GL_SAMPLER_2D ||
targetUniform->type == GL_SAMPLER_CUBE)
targetUniform->type == GL_SAMPLER_CUBE ||
targetUniform->type == GL_SAMPLER_EXTERNAL_OES)
{
for(int i = 0; i < count; i++)
{
......
......@@ -34,6 +34,7 @@ enum TextureType
{
TEXTURE_2D,
TEXTURE_CUBE,
TEXTURE_EXTERNAL,
TEXTURE_TYPE_COUNT,
TEXTURE_UNKNOWN
......
......@@ -48,27 +48,22 @@ sw::Resource *Texture::getResource() const
return resource;
}
bool Texture::isTexture2D()
{
return false;
}
bool Texture::isTextureCubeMap()
{
return false;
}
// Returns true on successful filter state update (valid enum parameter)
bool Texture::setMinFilter(GLenum filter)
{
switch(filter)
{
case GL_NEAREST:
case GL_LINEAR:
case GL_NEAREST_MIPMAP_NEAREST:
case GL_LINEAR_MIPMAP_NEAREST:
case GL_NEAREST_MIPMAP_LINEAR:
case GL_LINEAR_MIPMAP_LINEAR:
if(getTarget() == GL_TEXTURE_EXTERNAL_OES)
{
return false;
}
// Fall through
case GL_NEAREST:
case GL_LINEAR:
mMinFilter = filter;
return true;
default:
......@@ -96,8 +91,13 @@ bool Texture::setWrapS(GLenum wrap)
switch(wrap)
{
case GL_REPEAT:
case GL_CLAMP_TO_EDGE:
case GL_MIRRORED_REPEAT:
if(getTarget() == GL_TEXTURE_EXTERNAL_OES)
{
return false;
}
// Fall through
case GL_CLAMP_TO_EDGE:
mWrapS = wrap;
return true;
default:
......@@ -111,8 +111,13 @@ bool Texture::setWrapT(GLenum wrap)
switch(wrap)
{
case GL_REPEAT:
case GL_CLAMP_TO_EDGE:
case GL_MIRRORED_REPEAT:
if(getTarget() == GL_TEXTURE_EXTERNAL_OES)
{
return false;
}
// Fall through
case GL_CLAMP_TO_EDGE:
mWrapT = wrap;
return true;
default:
......@@ -312,11 +317,6 @@ Texture2D::~Texture2D()
mColorbufferProxy = NULL;
}
bool Texture2D::isTexture2D()
{
return true;
}
// We need to maintain a count of references to renderbuffers acting as
// proxies for this texture, so that we do not attempt to use a pointer
// to a renderbuffer proxy which has been deleted.
......@@ -730,11 +730,6 @@ TextureCubeMap::~TextureCubeMap()
}
}
bool TextureCubeMap::isTextureCubeMap()
{
return true;
}
// We need to maintain a count of references to renderbuffers acting as
// proxies for this texture, so that the texture is not deleted while
// proxy references still exist. If the reference count drops to zero,
......@@ -1127,6 +1122,34 @@ bool TextureCubeMap::isShared(GLenum target, unsigned int level) const
return image[face][level]->isShared();
}
TextureExternal::TextureExternal(GLuint id) : Texture2D(id)
{
mMinFilter = GL_LINEAR;
mMagFilter = GL_LINEAR;
mWrapS = GL_CLAMP_TO_EDGE;
mWrapT = GL_CLAMP_TO_EDGE;
}
TextureExternal::~TextureExternal()
{
}
GLenum TextureExternal::getTarget() const
{
return GL_TEXTURE_EXTERNAL_OES;
}
void TextureExternal::setImage(Image *sharedImage)
{
if(image[0])
{
image[0]->release();
}
sharedImage->addRef();
image[0] = sharedImage;
}
}
// Exported functions for use by EGL
......
......@@ -53,8 +53,6 @@ public:
virtual ~Texture();
sw::Resource *getResource() const;
virtual bool isTexture2D();
virtual bool isTextureCubeMap();
virtual void addProxyRef(const Renderbuffer *proxy) = 0;
virtual void releaseProxy(const Renderbuffer *proxy) = 0;
......@@ -118,8 +116,6 @@ public:
virtual ~Texture2D();
virtual bool isTexture2D();
void addProxyRef(const Renderbuffer *proxy);
void releaseProxy(const Renderbuffer *proxy);
......@@ -153,7 +149,7 @@ public:
Image *getImage(unsigned int level);
private:
protected:
bool isMipmapComplete() const;
Image *image[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
......@@ -176,8 +172,6 @@ public:
virtual ~TextureCubeMap();
virtual bool isTextureCubeMap();
void addProxyRef(const Renderbuffer *proxy);
void releaseProxy(const Renderbuffer *proxy);
......@@ -227,6 +221,18 @@ private:
Renderbuffer *mFaceProxies[6];
unsigned int mFaceProxyRefs[6];
};
class TextureExternal : public Texture2D
{
public:
explicit TextureExternal(GLuint id);
virtual ~TextureExternal();
virtual GLenum getTarget() const;
void setImage(Image *image);
};
}
#endif // LIBGLESV2_TEXTURE_H_
......@@ -31,6 +31,7 @@ namespace gl
case GL_INT:
case GL_SAMPLER_2D:
case GL_SAMPLER_CUBE:
case GL_SAMPLER_EXTERNAL_OES:
return 1;
case GL_BOOL_VEC2:
case GL_FLOAT_VEC2:
......@@ -76,6 +77,7 @@ namespace gl
case GL_INT:
case GL_SAMPLER_2D:
case GL_SAMPLER_CUBE:
case GL_SAMPLER_EXTERNAL_OES:
case GL_INT_VEC2:
case GL_INT_VEC3:
case GL_INT_VEC4:
......@@ -119,6 +121,7 @@ namespace gl
case GL_INT_VEC4:
case GL_SAMPLER_2D:
case GL_SAMPLER_CUBE:
case GL_SAMPLER_EXTERNAL_OES:
return 1;
case GL_FLOAT_MAT2:
return 2;
......
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