Commit f7bbc8a3 by JiangYizhou Committed by Commit Bot

ES3.1: Implement framebuffer parameters api for opengl part.

Add new framebuffer parameters that can be set with glFramebufferParameteri and queried with glGetFramebufferParameteriv. GL_FRAMEBUFFER DEFAULT WIDTH GL_FRAMEBUFFER_DEFAULT_HEIGHT GL_FRAMEBUFFER_DEFAULT_SAMPLES GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS BUG=angleproject:1594 TEST=angle_unittests TEST=angle_end2end_tests TEST=dEQP-GLES31.functional.state_query.framebuffer_default.framebuffer_default* Change-Id: I425e73a6b798fc7c73841ab98d7c8aabc381133d Reviewed-on: https://chromium-review.googlesource.com/412126Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 558d645d
......@@ -45,7 +45,11 @@ FramebufferState::FramebufferState()
: mLabel(),
mColorAttachments(1),
mDrawBufferStates(1, GL_NONE),
mReadBufferState(GL_COLOR_ATTACHMENT0_EXT)
mReadBufferState(GL_COLOR_ATTACHMENT0_EXT),
mDefaultWidth(0),
mDefaultHeight(0),
mDefaultSamples(0),
mDefaultFixedSampleLocations(GL_FALSE)
{
mDrawBufferStates[0] = GL_COLOR_ATTACHMENT0_EXT;
mEnabledDrawBuffers.set(0);
......@@ -55,7 +59,11 @@ FramebufferState::FramebufferState(const Caps &caps)
: mLabel(),
mColorAttachments(caps.maxColorAttachments),
mDrawBufferStates(caps.maxDrawBuffers, GL_NONE),
mReadBufferState(GL_COLOR_ATTACHMENT0_EXT)
mReadBufferState(GL_COLOR_ATTACHMENT0_EXT),
mDefaultWidth(0),
mDefaultHeight(0),
mDefaultSamples(0),
mDefaultFixedSampleLocations(GL_FALSE)
{
ASSERT(mDrawBufferStates.size() > 0);
mDrawBufferStates[0] = GL_COLOR_ATTACHMENT0_EXT;
......@@ -555,6 +563,7 @@ GLenum Framebuffer::checkStatusImpl(const ContextState &state)
int samples = -1;
bool missingAttachment = true;
// TODO(yizhou): Check status for default framebuffer parameters.
for (const FramebufferAttachment &colorAttachment : mState.mColorAttachments)
{
if (colorAttachment.isAttached())
......@@ -1106,4 +1115,48 @@ bool Framebuffer::formsCopyingFeedbackLoopWith(GLuint copyTextureID,
return false;
}
GLint Framebuffer::getDefaultWidth() const
{
return mState.getDefaultWidth();
}
GLint Framebuffer::getDefaultHeight() const
{
return mState.getDefaultHeight();
}
GLint Framebuffer::getDefaultSamples() const
{
return mState.getDefaultSamples();
}
GLboolean Framebuffer::getDefaultFixedSampleLocations() const
{
return mState.getDefaultFixedSampleLocations();
}
void Framebuffer::setDefaultWidth(GLint defaultWidth)
{
mState.mDefaultWidth = defaultWidth;
mDirtyBits.set(DIRTY_BIT_DEFAULT_WIDTH);
}
void Framebuffer::setDefaultHeight(GLint defaultHeight)
{
mState.mDefaultHeight = defaultHeight;
mDirtyBits.set(DIRTY_BIT_DEFAULT_HEIGHT);
}
void Framebuffer::setDefaultSamples(GLint defaultSamples)
{
mState.mDefaultSamples = defaultSamples;
mDirtyBits.set(DIRTY_BIT_DEFAULT_SAMPLES);
}
void Framebuffer::setDefaultFixedSampleLocations(GLboolean defaultFixedSampleLocations)
{
mState.mDefaultFixedSampleLocations = defaultFixedSampleLocations;
mDirtyBits.set(DIRTY_BIT_DEFAULT_FIXED_SAMPLE_LOCATIONS);
}
} // namespace gl
......@@ -83,6 +83,11 @@ class FramebufferState final : angle::NonCopyable
const FramebufferAttachment *getDrawBuffer(size_t drawBufferIdx) const;
size_t getDrawBufferCount() const;
GLint getDefaultWidth() const { return mDefaultWidth; };
GLint getDefaultHeight() const { return mDefaultHeight; };
GLint getDefaultSamples() const { return mDefaultSamples; };
GLboolean getDefaultFixedSampleLocations() const { return mDefaultFixedSampleLocations; };
private:
friend class Framebuffer;
......@@ -95,6 +100,11 @@ class FramebufferState final : angle::NonCopyable
std::vector<GLenum> mDrawBufferStates;
GLenum mReadBufferState;
std::bitset<IMPLEMENTATION_MAX_DRAW_BUFFERS> mEnabledDrawBuffers;
GLint mDefaultWidth;
GLint mDefaultHeight;
GLint mDefaultSamples;
GLboolean mDefaultFixedSampleLocations;
};
class Framebuffer final : public LabeledObject, public angle::SignalReceiver
......@@ -160,6 +170,15 @@ class Framebuffer final : public LabeledObject, public angle::SignalReceiver
Error getSamplePosition(size_t index, GLfloat *xy) const;
GLint getDefaultWidth() const;
GLint getDefaultHeight() const;
GLint getDefaultSamples() const;
GLboolean getDefaultFixedSampleLocations() const;
void setDefaultWidth(GLint defaultWidth);
void setDefaultHeight(GLint defaultHeight);
void setDefaultSamples(GLint defaultSamples);
void setDefaultFixedSampleLocations(GLboolean defaultFixedSampleLocations);
GLenum checkStatus(const ContextState &state);
// Helper for checkStatus == GL_FRAMEBUFFER_COMPLETE.
......@@ -213,8 +232,12 @@ class Framebuffer final : public LabeledObject, public angle::SignalReceiver
DIRTY_BIT_STENCIL_ATTACHMENT,
DIRTY_BIT_DRAW_BUFFERS,
DIRTY_BIT_READ_BUFFER,
DIRTY_BIT_DEFAULT_WIDTH,
DIRTY_BIT_DEFAULT_HEIGHT,
DIRTY_BIT_DEFAULT_SAMPLES,
DIRTY_BIT_DEFAULT_FIXED_SAMPLE_LOCATIONS,
DIRTY_BIT_UNKNOWN,
DIRTY_BIT_MAX = DIRTY_BIT_UNKNOWN,
DIRTY_BIT_MAX = DIRTY_BIT_UNKNOWN
};
typedef std::bitset<DIRTY_BIT_MAX> DirtyBits;
......
......@@ -426,7 +426,7 @@ ImageDesc::ImageDesc(const Extents &size, const Format &format)
ImageDesc::ImageDesc(const Extents &size,
const Format &format,
const GLsizei samples,
GLboolean fixedSampleLocations)
const GLboolean fixedSampleLocations)
: size(size), format(format), samples(samples), fixedSampleLocations(fixedSampleLocations)
{
}
......
......@@ -49,11 +49,10 @@ struct ImageDesc final
{
ImageDesc();
ImageDesc(const Extents &size, const Format &format);
ImageDesc(const Extents &size,
const Format &format,
const GLsizei samples,
GLboolean fixedSampleLocations);
const GLboolean fixedSampleLocations);
ImageDesc(const ImageDesc &other) = default;
ImageDesc &operator=(const ImageDesc &other) = default;
......
......@@ -832,6 +832,30 @@ void QueryInternalFormativ(const TextureCaps &format, GLenum pname, GLsizei bufS
}
}
void QueryFramebufferParameteriv(const Framebuffer *framebuffer, GLenum pname, GLint *params)
{
ASSERT(framebuffer);
switch (pname)
{
case GL_FRAMEBUFFER_DEFAULT_WIDTH:
*params = framebuffer->getDefaultWidth();
break;
case GL_FRAMEBUFFER_DEFAULT_HEIGHT:
*params = framebuffer->getDefaultHeight();
break;
case GL_FRAMEBUFFER_DEFAULT_SAMPLES:
*params = framebuffer->getDefaultSamples();
break;
case GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS:
*params = framebuffer->getDefaultFixedSampleLocations();
break;
default:
UNREACHABLE();
break;
}
}
void SetTexParameterf(Texture *texture, GLenum pname, GLfloat param)
{
SetTexParameterBase(texture, pname, &param);
......@@ -872,6 +896,30 @@ void SetSamplerParameteriv(Sampler *sampler, GLenum pname, const GLint *params)
SetSamplerParameterBase(sampler, pname, params);
}
void SetFramebufferParameteri(Framebuffer *framebuffer, GLenum pname, GLint param)
{
ASSERT(framebuffer);
switch (pname)
{
case GL_FRAMEBUFFER_DEFAULT_WIDTH:
framebuffer->setDefaultWidth(param);
break;
case GL_FRAMEBUFFER_DEFAULT_HEIGHT:
framebuffer->setDefaultHeight(param);
break;
case GL_FRAMEBUFFER_DEFAULT_SAMPLES:
framebuffer->setDefaultSamples(param);
break;
case GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS:
framebuffer->setDefaultFixedSampleLocations(static_cast<GLboolean>(param));
break;
default:
UNREACHABLE();
break;
}
}
} // namespace gl
namespace egl
......
......@@ -76,6 +76,7 @@ void QueryActiveUniformBlockiv(const Program *program,
GLint *params);
void QueryInternalFormativ(const TextureCaps &format, GLenum pname, GLsizei bufSize, GLint *params);
void QueryFramebufferParameteriv(const Framebuffer *framebuffer, GLenum pname, GLint *params);
void SetTexParameterf(Texture *texture, GLenum pname, GLfloat param);
void SetTexParameterfv(Texture *texture, GLenum pname, const GLfloat *params);
......@@ -86,6 +87,7 @@ void SetSamplerParameterf(Sampler *sampler, GLenum pname, GLfloat param);
void SetSamplerParameterfv(Sampler *sampler, GLenum pname, const GLfloat *params);
void SetSamplerParameteri(Sampler *sampler, GLenum pname, GLint param);
void SetSamplerParameteriv(Sampler *sampler, GLenum pname, const GLint *params);
void SetFramebufferParameteri(Framebuffer *framebuffer, GLenum pname, GLint param);
} // namespace gl
......
......@@ -419,6 +419,23 @@ void FramebufferGL::syncState(const Framebuffer::DirtyBits &dirtyBits)
case Framebuffer::DIRTY_BIT_READ_BUFFER:
mFunctions->readBuffer(mState.getReadBufferState());
break;
case Framebuffer::DIRTY_BIT_DEFAULT_WIDTH:
mFunctions->framebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_WIDTH,
mState.getDefaultWidth());
break;
case Framebuffer::DIRTY_BIT_DEFAULT_HEIGHT:
mFunctions->framebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_HEIGHT,
mState.getDefaultHeight());
break;
case Framebuffer::DIRTY_BIT_DEFAULT_SAMPLES:
mFunctions->framebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_SAMPLES,
mState.getDefaultSamples());
break;
case Framebuffer::DIRTY_BIT_DEFAULT_FIXED_SAMPLE_LOCATIONS:
mFunctions->framebufferParameteri(GL_FRAMEBUFFER,
GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS,
mState.getDefaultFixedSampleLocations());
break;
default:
{
ASSERT(Framebuffer::DIRTY_BIT_COLOR_ATTACHMENT_0 == 0 &&
......
......@@ -9,6 +9,7 @@
#include "libANGLE/validationES31.h"
#include "libANGLE/Context.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/validationES.h"
#include "libANGLE/validationES3.h"
#include "libANGLE/VertexArray.h"
......@@ -388,4 +389,120 @@ bool ValidateGetMultisamplefv(Context *context, GLenum pname, GLuint index, GLfl
return true;
}
bool ValidationFramebufferParameteri(Context *context, GLenum target, GLenum pname, GLint param)
{
if (context->getClientVersion() < ES_3_1)
{
context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.1."));
return false;
}
if (!ValidFramebufferTarget(target))
{
context->handleError(Error(GL_INVALID_ENUM, "Invalid framebuffer target."));
return false;
}
switch (pname)
{
case GL_FRAMEBUFFER_DEFAULT_WIDTH:
{
GLint maxWidth = context->getCaps().maxFramebufferWidth;
if (param < 0 || param > maxWidth)
{
context->handleError(
Error(GL_INVALID_VALUE,
"Params less than 0 or greater than GL_MAX_FRAMEBUFFER_WIDTH."));
return false;
}
break;
}
case GL_FRAMEBUFFER_DEFAULT_HEIGHT:
{
GLint maxHeight = context->getCaps().maxFramebufferHeight;
if (param < 0 || param > maxHeight)
{
context->handleError(
Error(GL_INVALID_VALUE,
"Params less than 0 or greater than GL_MAX_FRAMEBUFFER_HEIGHT."));
return false;
}
break;
}
case GL_FRAMEBUFFER_DEFAULT_SAMPLES:
{
GLint maxSamples = context->getCaps().maxFramebufferSamples;
if (param < 0 || param > maxSamples)
{
context->handleError(
Error(GL_INVALID_VALUE,
"Params less than 0 or greater than GL_MAX_FRAMEBUFFER_SAMPLES."));
return false;
}
break;
}
case GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS:
{
break;
}
default:
{
context->handleError(Error(GL_INVALID_ENUM, "Invalid pname: 0x%X", pname));
return false;
}
}
const Framebuffer *framebuffer = context->getGLState().getTargetFramebuffer(target);
ASSERT(framebuffer);
if (framebuffer->id() == 0)
{
context->handleError(
Error(GL_INVALID_OPERATION, "Default framebuffer is bound to target."));
return false;
}
return true;
}
bool ValidationGetFramebufferParameteri(Context *context,
GLenum target,
GLenum pname,
GLint *params)
{
if (context->getClientVersion() < ES_3_1)
{
context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.1."));
return false;
}
if (!ValidFramebufferTarget(target))
{
context->handleError(Error(GL_INVALID_ENUM, "Invalid framebuffer target."));
return false;
}
switch (pname)
{
case GL_FRAMEBUFFER_DEFAULT_WIDTH:
case GL_FRAMEBUFFER_DEFAULT_HEIGHT:
case GL_FRAMEBUFFER_DEFAULT_SAMPLES:
case GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS:
break;
default:
context->handleError(Error(GL_INVALID_ENUM, "Invalid pname: 0x%X", pname));
return false;
}
const Framebuffer *framebuffer = context->getGLState().getTargetFramebuffer(target);
ASSERT(framebuffer);
if (framebuffer->id() == 0)
{
context->handleError(
Error(GL_INVALID_OPERATION, "Default framebuffer is bound to target."));
return false;
}
return true;
}
} // namespace gl
......@@ -50,6 +50,11 @@ bool ValidateDrawElementsIndirect(Context *context,
GLenum type,
const GLvoid *indirect);
bool ValidationFramebufferParameteri(Context *context, GLenum target, GLenum pname, GLint param);
bool ValidationGetFramebufferParameteri(Context *context,
GLenum target,
GLenum pname,
GLint *params);
} // namespace gl
#endif // LIBANGLE_VALIDATION_ES31_H_
......@@ -89,11 +89,14 @@ void GL_APIENTRY FramebufferParameteri(GLenum target, GLenum pname, GLint param)
Context *context = GetValidGlobalContext();
if (context)
{
if (!context->skipValidation())
if (!context->skipValidation() &&
!ValidationFramebufferParameteri(context, target, pname, param))
{
context->handleError(Error(GL_INVALID_OPERATION, "Entry point not implemented"));
return;
}
UNIMPLEMENTED();
Framebuffer *framebuffer = context->getGLState().getTargetFramebuffer(target);
SetFramebufferParameteri(framebuffer, pname, param);
}
}
......@@ -104,11 +107,14 @@ void GL_APIENTRY GetFramebufferParameteriv(GLenum target, GLenum pname, GLint *p
Context *context = GetValidGlobalContext();
if (context)
{
if (!context->skipValidation())
if (!context->skipValidation() &&
!ValidationGetFramebufferParameteri(context, target, pname, params))
{
context->handleError(Error(GL_INVALID_OPERATION, "Entry point not implemented"));
return;
}
UNIMPLEMENTED();
Framebuffer *framebuffer = context->getGLState().getTargetFramebuffer(target);
QueryFramebufferParameteriv(framebuffer, pname, params);
}
}
......
......@@ -147,6 +147,10 @@
1442 D3D11 : dEQP-GLES31.functional.state_query.internal_format.renderbuffer.* = FAIL
1679 D3D11 : dEQP-GLES31.functional.state_query.texture_level.texture_2d_multisample.* = FAIL
1442 D3D11 : dEQP-GLES31.functional.texture.multisample.* = FAIL
1442 D3D11 : dEQP-GLES31.functional.state_query.framebuffer_default.framebuffer_default_width_get_framebuffer_parameteriv = FAIL
1442 D3D11 : dEQP-GLES31.functional.state_query.framebuffer_default.framebuffer_default_height_get_framebuffer_parameteriv = FAIL
1442 D3D11 : dEQP-GLES31.functional.state_query.framebuffer_default.framebuffer_default_samples_get_framebuffer_parameteriv = FAIL
1442 D3D11 : dEQP-GLES31.functional.state_query.framebuffer_default.framebuffer_default_fixed_sample_locations_get_framebuffer_parameteriv = FAIL
1442 D3D11 : dEQP-GLES31.functional.debug.negative_coverage.callbacks.texture.texparameter* = SKIP
1442 D3D11 : dEQP-GLES31.functional.debug.negative_coverage.get_error.texture.texparameter* = SKIP
1442 D3D11 : dEQP-GLES31.functional.debug.negative_coverage.log.texture.texparameter* = SKIP
......@@ -1361,10 +1365,6 @@
1442 OPENGL D3D11 : dEQP-GLES31.functional.state_query.internal_format.partial_query.num_sample_counts = FAIL
1442 OPENGL D3D11 : dEQP-GLES31.functional.state_query.internal_format.partial_query.samples = FAIL
1442 OPENGL D3D11 : dEQP-GLES31.functional.state_query.vertex_attribute_binding.* = FAIL
1442 OPENGL D3D11 : dEQP-GLES31.functional.state_query.framebuffer_default.framebuffer_default_width_get_framebuffer_parameteriv = FAIL
1442 OPENGL D3D11 : dEQP-GLES31.functional.state_query.framebuffer_default.framebuffer_default_height_get_framebuffer_parameteriv = FAIL
1442 OPENGL D3D11 : dEQP-GLES31.functional.state_query.framebuffer_default.framebuffer_default_samples_get_framebuffer_parameteriv = FAIL
1442 OPENGL D3D11 : dEQP-GLES31.functional.state_query.framebuffer_default.framebuffer_default_fixed_sample_locations_get_framebuffer_parameteriv = FAIL
1442 OPENGL D3D11 : dEQP-GLES31.functional.state_query.program.program_separable_get_programiv = FAIL
1442 OPENGL D3D11 : dEQP-GLES31.functional.state_query.program.compute_work_group_size_get_programiv = FAIL
1442 OPENGL D3D11 : dEQP-GLES31.functional.state_query.program.active_atomic_counter_buffers_get_programiv = FAIL
......
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