return GL_NO_ERROR;\r
}\r
\r
-int Context::getSupportedMultiSampleDepth(sw::Format format, int requested)\r
+int Context::getSupportedMultisampleCount(int requested)\r
{\r
- if(requested <= 0)\r
- {\r
- return 0;\r
- }\r
- \r
- if(requested <= 2)\r
+ int supported = 0;\r
+\r
+ for(int i = NUM_MULTISAMPLE_COUNTS - 1; i >= 0; i--)\r
{\r
- return requested;\r
+ if(supported >= requested)\r
+ {\r
+ return supported;\r
+ }\r
+\r
+ supported = multisampleCount[i];\r
}\r
- \r
- return 4;\r
+\r
+ return supported;\r
}\r
\r
void Context::detachBuffer(GLuint buffer)\r
\r
const GLint NUM_COMPRESSED_TEXTURE_FORMATS = sizeof(compressedTextureFormats) / sizeof(compressedTextureFormats[0]);\r
\r
+const GLint multisampleCount[] = {4, 2, 1};\r
+const GLint NUM_MULTISAMPLE_COUNTS = sizeof(multisampleCount) / sizeof(multisampleCount[0]);\r
+const GLint IMPLEMENTATION_MAX_SAMPLES = multisampleCount[0];\r
+\r
const float ALIASED_LINE_WIDTH_RANGE_MIN = 1.0f;\r
const float ALIASED_LINE_WIDTH_RANGE_MAX = 128.0f;\r
const float ALIASED_POINT_SIZE_RANGE_MIN = 0.125f;\r
\r
GLenum getError();\r
\r
- static int getSupportedMultiSampleDepth(sw::Format format, int requested);\r
+ static int getSupportedMultisampleCount(int requested);\r
\r
void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, \r
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,\r
}
}
-Colorbuffer::Colorbuffer(int width, int height, GLenum format, GLsizei samples) : mRenderTarget(NULL)
+Colorbuffer::Colorbuffer(int width, int height, GLenum format, GLsizei samples) : mRenderTarget(nullptr)
{
Device *device = getDevice();
sw::Format requestedFormat = es2sw::ConvertRenderbufferFormat(format);
- int supportedSamples = Context::getSupportedMultiSampleDepth(requestedFormat, samples);
+ int supportedSamples = Context::getSupportedMultisampleCount(samples);
if(width > 0 && height > 0)
{
}
}
-DepthStencilbuffer::DepthStencilbuffer(int width, int height, GLsizei samples)
+DepthStencilbuffer::DepthStencilbuffer(int width, int height, GLsizei samples) : mDepthStencil(nullptr)
{
Device *device = getDevice();
- mDepthStencil = NULL;
-
- int supportedSamples = Context::getSupportedMultiSampleDepth(sw::FORMAT_D24S8, samples);
+ int supportedSamples = Context::getSupportedMultisampleCount(samples);
if(width > 0 && height > 0)
{
IMPLEMENTATION_MAX_TEXTURE_SIZE = 1 << (MIPMAP_LEVELS - 1),\r
IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE = 1 << (MIPMAP_LEVELS - 1),\r
IMPLEMENTATION_MAX_RENDERBUFFER_SIZE = OUTLINE_RESOLUTION,\r
- IMPLEMENTATION_MAX_SAMPLES = 4\r
};\r
\r
class Texture : public NamedObject\r
return GL_NO_ERROR;\r
}\r
\r
-int Context::getSupportedMultiSampleDepth(sw::Format format, int requested)\r
+int Context::getSupportedMultisampleCount(int requested)\r
{\r
- if(requested <= 0)\r
- {\r
- return 0;\r
- }\r
+ int supported = 0;\r
\r
- if(requested <= 2)\r
+ for(int i = NUM_MULTISAMPLE_COUNTS - 1; i >= 0; i--)\r
{\r
- return requested;\r
+ if(supported >= requested)\r
+ {\r
+ return supported;\r
+ }\r
+\r
+ supported = multisampleCount[i];\r
}\r
\r
- return 4;\r
+ return supported;\r
}\r
\r
void Context::detachBuffer(GLuint buffer)\r
\r
const GLint NUM_COMPRESSED_TEXTURE_FORMATS = sizeof(compressedTextureFormats) / sizeof(compressedTextureFormats[0]);\r
\r
+const GLint multisampleCount[] = {4, 2, 1};\r
+const GLint NUM_MULTISAMPLE_COUNTS = sizeof(multisampleCount) / sizeof(multisampleCount[0]);\r
+const GLint IMPLEMENTATION_MAX_SAMPLES = multisampleCount[0];\r
+\r
const float ALIASED_LINE_WIDTH_RANGE_MIN = 1.0f;\r
const float ALIASED_LINE_WIDTH_RANGE_MAX = 1.0f;\r
const float ALIASED_POINT_SIZE_RANGE_MIN = 0.125f;\r
\r
GLenum getError();\r
\r
- static int getSupportedMultiSampleDepth(sw::Format format, int requested);\r
+ static int getSupportedMultisampleCount(int requested);\r
\r
virtual void bindTexImage(egl::Surface *surface);\r
virtual EGLenum validateSharedImage(EGLenum target, GLuint name, GLuint textureLevel);\r
}
}
-Colorbuffer::Colorbuffer(int width, int height, GLenum format, GLsizei samples) : mRenderTarget(NULL)
+Colorbuffer::Colorbuffer(int width, int height, GLenum format, GLsizei samples) : mRenderTarget(nullptr)
{
Device *device = getDevice();
sw::Format requestedFormat = es2sw::ConvertRenderbufferFormat(format);
- int supportedSamples = Context::getSupportedMultiSampleDepth(requestedFormat, samples);
+ int supportedSamples = Context::getSupportedMultisampleCount(samples);
if(width > 0 && height > 0)
{
}
}
-DepthStencilbuffer::DepthStencilbuffer(int width, int height, GLsizei samples)
+DepthStencilbuffer::DepthStencilbuffer(int width, int height, GLsizei samples) : mDepthStencil(nullptr)
{
Device *device = getDevice();
-
- mDepthStencil = NULL;
- int supportedSamples = Context::getSupportedMultiSampleDepth(sw::FORMAT_D24S8, samples);
+ int supportedSamples = Context::getSupportedMultisampleCount(samples);
if(width > 0 && height > 0)
{
IMPLEMENTATION_MAX_TEXTURE_SIZE = 1 << (MIPMAP_LEVELS - 1),\r
IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE = 1 << (MIPMAP_LEVELS - 1),\r
IMPLEMENTATION_MAX_RENDERBUFFER_SIZE = OUTLINE_RESOLUTION,\r
- IMPLEMENTATION_MAX_SAMPLES = 4\r
};\r
\r
class Texture : public egl::Texture\r
return GL_NO_ERROR;\r
}\r
\r
-int Context::getSupportedMultiSampleDepth(sw::Format format, int requested)\r
+int Context::getSupportedMultisampleCount(int requested)\r
{\r
- if(requested <= 0)\r
- {\r
- return 0;\r
- }\r
- \r
- if(requested <= 2)\r
+ int supported = 0;\r
+\r
+ for(int i = NUM_MULTISAMPLE_COUNTS - 1; i >= 0; i--)\r
{\r
- return requested;\r
+ if(supported >= requested)\r
+ {\r
+ return supported;\r
+ }\r
+\r
+ supported = multisampleCount[i];\r
}\r
- \r
- return 4;\r
+\r
+ return supported;\r
}\r
\r
void Context::detachBuffer(GLuint buffer)\r
\r
const GLint NUM_COMPRESSED_TEXTURE_FORMATS = sizeof(compressedTextureFormats) / sizeof(compressedTextureFormats[0]);\r
\r
+const GLint multisampleCount[] = {4, 2, 1};\r
+const GLint NUM_MULTISAMPLE_COUNTS = sizeof(multisampleCount) / sizeof(multisampleCount[0]);\r
+const GLint IMPLEMENTATION_MAX_SAMPLES = multisampleCount[0];\r
+\r
const float ALIASED_LINE_WIDTH_RANGE_MIN = 1.0f;\r
const float ALIASED_LINE_WIDTH_RANGE_MAX = 1.0f;\r
const float ALIASED_POINT_SIZE_RANGE_MIN = 0.125f;\r
\r
GLenum getError();\r
\r
- static int getSupportedMultiSampleDepth(sw::Format format, int requested);\r
+ static int getSupportedMultisampleCount(int requested);\r
\r
void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, \r
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,\r
}
}
-Colorbuffer::Colorbuffer(int width, int height, GLenum format, GLsizei samples) : mRenderTarget(NULL)
+Colorbuffer::Colorbuffer(int width, int height, GLenum format, GLsizei samples) : mRenderTarget(nullptr)
{
Device *device = getDevice();
sw::Format requestedFormat = es2sw::ConvertRenderbufferFormat(format);
- int supportedSamples = Context::getSupportedMultiSampleDepth(requestedFormat, samples);
+ int supportedSamples = Context::getSupportedMultisampleCount(samples);
if(width > 0 && height > 0)
{
}
}
-DepthStencilbuffer::DepthStencilbuffer(int width, int height, GLsizei samples)
+DepthStencilbuffer::DepthStencilbuffer(int width, int height, GLsizei samples) : mDepthStencil(nullptr)
{
Device *device = getDevice();
- mDepthStencil = NULL;
-
- int supportedSamples = Context::getSupportedMultiSampleDepth(sw::FORMAT_D24S8, samples);
+ int supportedSamples = Context::getSupportedMultisampleCount(samples);
if(width > 0 && height > 0)
{
IMPLEMENTATION_MAX_TEXTURE_SIZE = 1 << (MIPMAP_LEVELS - 1),\r
IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE = 1 << (MIPMAP_LEVELS - 1),\r
IMPLEMENTATION_MAX_RENDERBUFFER_SIZE = OUTLINE_RESOLUTION,\r
- IMPLEMENTATION_MAX_SAMPLES = 4,\r
IMPLEMENTATION_MAX_COLOR_ATTACHMENTS = MAX_COLOR_ATTACHMENTS,\r
IMPLEMENTATION_MAX_DRAW_BUFFERS = 8,\r
IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS = MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS,\r
return error(GL_INVALID_ENUM);\r
}\r
\r
- sw::Format requestedFormat = es2sw::ConvertRenderbufferFormat(internalformat);\r
- std::vector<GLint> supportedMultiSampleDepths;\r
- int maxDepth = Context::getSupportedMultiSampleDepth(requestedFormat, INT_MAX);\r
- for(int depth = maxDepth; depth > 1;)\r
- {\r
- supportedMultiSampleDepths.push_back(depth);\r
- for(int nextDepth = depth - 1; nextDepth >= 0; --nextDepth)\r
- {\r
- int supportedDepth = Context::getSupportedMultiSampleDepth(requestedFormat, nextDepth);\r
- if(supportedDepth != depth)\r
- {\r
- depth = supportedDepth;\r
- break;\r
- }\r
- }\r
- }\r
-\r
switch(pname)\r
{\r
case GL_NUM_SAMPLE_COUNTS:\r
- *params = supportedMultiSampleDepths.size();\r
+ *params = NUM_MULTISAMPLE_COUNTS;\r
break;\r
case GL_SAMPLES:\r
+ for(int i = 0; i < NUM_MULTISAMPLE_COUNTS && i < bufSize; i++)\r
{\r
- size_t returnCount = std::min<size_t>(bufSize, supportedMultiSampleDepths.size());\r
- for(size_t sampleIndex = 0; sampleIndex < returnCount; ++sampleIndex)\r
- {\r
- params[sampleIndex] = supportedMultiSampleDepths[sampleIndex];\r
- }\r
+ params[i] = multisampleCount[i];\r
}\r
break;\r
default:\r