Commit 640dc659 authored by zmo's avatar zmo Committed by Commit bot

Emulate GL_PRIMITIVE_RESTART_FIXED_INDEX: part I

Note that this is only partial implementation.

BUG=481184,480709
TEST=gpu_unittests
R=piman@chromium.org

Review URL: https://codereview.chromium.org/1106833002

Cr-Commit-Position: refs/heads/master@{#327202}
parent ce954eec
......@@ -285,16 +285,8 @@ ErrorState* ContextState::GetErrorState() {
void ContextState::EnableDisable(GLenum pname, bool enable) const {
if (pname == GL_PRIMITIVE_RESTART_FIXED_INDEX) {
// This is only available on Desktop GL 4.3+, but we emulate ES 3.0 on top
// of Desktop GL 4.2+.
const gfx::GLVersionInfo& gl_version = feature_info_->gl_version_info();
if (!gl_version.is_es &&
(gl_version.major_version < 4 ||
(gl_version.major_version == 4 && gl_version.minor_version < 3))) {
// TODO(zmo): Ignoring it may not be the best emulation.
NOTIMPLEMENTED();
return;
}
if (feature_info_->feature_flags().emulate_primitive_restart_fixed_index)
pname = GL_PRIMITIVE_RESTART;
}
if (enable) {
glEnable(pname);
......
......@@ -161,7 +161,8 @@ FeatureInfo::FeatureFlags::FeatureFlags()
blend_equation_advanced(false),
blend_equation_advanced_coherent(false),
ext_texture_rg(false),
enable_subscribe_uniform(false) {
enable_subscribe_uniform(false),
emulate_primitive_restart_fixed_index(false) {
}
FeatureInfo::Workarounds::Workarounds() :
......@@ -1097,6 +1098,13 @@ void FeatureInfo::InitializeFeatures() {
gfx::GLFenceEGL::SetIgnoreFailures();
}
#endif
if (gl_version_info_->IsLowerThanGL(4, 3)) {
// crbug.com/481184.
// GL_PRIMITIVE_RESTART_FIXED_INDEX is only available on Desktop GL 4.3+,
// but we emulate ES 3.0 on top of Desktop GL 4.2+.
feature_flags_.emulate_primitive_restart_fixed_index = true;
}
}
bool FeatureInfo::IsES3Capable() const {
......
......@@ -78,6 +78,7 @@ class GPU_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> {
bool blend_equation_advanced_coherent;
bool ext_texture_rg;
bool enable_subscribe_uniform;
bool emulate_primitive_restart_fixed_index;
};
struct Workarounds {
......
......@@ -7073,6 +7073,9 @@ error::Error GLES2DecoderImpl::DoDrawArrays(
error::Error GLES2DecoderImpl::HandleDrawArrays(uint32 immediate_data_size,
const void* cmd_data) {
// TODO(zmo): crbug.com/481184
// On Desktop GL with versions lower than 4.3, we need to emulate
// GL_PRIMITIVE_RESTART_FIXED_INDEX using glPrimitiveRestartIndex().
const cmds::DrawArrays& c = *static_cast<const cmds::DrawArrays*>(cmd_data);
return DoDrawArrays("glDrawArrays",
false,
......@@ -7216,6 +7219,9 @@ error::Error GLES2DecoderImpl::DoDrawElements(
error::Error GLES2DecoderImpl::HandleDrawElements(uint32 immediate_data_size,
const void* cmd_data) {
// TODO(zmo): crbug.com/481184
// On Desktop GL with versions lower than 4.3, we need to emulate
// GL_PRIMITIVE_RESTART_FIXED_INDEX using glPrimitiveRestartIndex().
const gles2::cmds::DrawElements& c =
*static_cast<const gles2::cmds::DrawElements*>(cmd_data);
return DoDrawElements("glDrawElements",
......
......@@ -24,6 +24,11 @@ struct GL_EXPORT GLVersionInfo {
(major_version == major && minor_version >= minor));
}
bool IsLowerThanGL(unsigned major, unsigned minor) const {
return !is_es && (major_version < major ||
(major_version == major && minor_version < minor));
}
bool IsAtLeastGLES(unsigned major, unsigned minor) const {
return is_es && (major_version > major ||
(major_version == major && minor_version >= minor));
......
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