Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 1309743005: command_buffer: Implement EXT_blend_func_extended (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new-05-path-fragment-input-gen
Patch Set: ~ Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/gles2_cmd_decoder.cc
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 7b675abfb84f01e4d07061ea1c2fb8edae12342e..29902bf4141f4d14d0f1294944be24183b6ceb90 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -1270,6 +1270,16 @@ class GLES2DecoderImpl : public GLES2Decoder,
}
void DoBindAttribLocation(GLuint client_id, GLuint index, const char* name);
+
+ error::Error DoBindFragDataLocation(GLuint program_id,
+ GLuint colorName,
+ const char* name);
+
+ error::Error DoBindFragDataLocationIndexed(GLuint program_id,
+ GLuint colorName,
+ GLuint index,
+ const char* name);
+
void DoBindUniformLocationCHROMIUM(
GLuint client_id, GLint location, const char* name);
@@ -1285,6 +1295,11 @@ class GLES2DecoderImpl : public GLES2Decoder,
GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
const std::string& name_str);
+ error::Error GetFragDataIndexHelper(GLuint program_id,
+ uint32 index_shm_id,
+ uint32 index_shm_offset,
+ const std::string& name_str);
+
// Wrapper for glShaderSource.
void DoShaderSource(
GLuint client_id, GLsizei count, const char** data, const GLint* length);
@@ -3260,6 +3275,7 @@ bool GLES2DecoderImpl::InitializeShaderTranslator() {
resources.MaxDrawBuffers = group_->max_draw_buffers();
resources.MaxExpressionComplexity = 256;
resources.MaxCallStackDepth = 256;
+ resources.MaxDualSourceDrawBuffers = group_->max_dual_source_draw_buffers();
GLint range[2] = { 0, 0 };
GLint precision = 0;
@@ -3292,6 +3308,8 @@ bool GLES2DecoderImpl::InitializeShaderTranslator() {
features().ext_shader_texture_lod ? 1 : 0;
resources.NV_draw_buffers =
features().nv_draw_buffers ? 1 : 0;
+ resources.EXT_blend_func_extended =
+ features().ext_blend_func_extended ? 1 : 0;
}
ShShaderSpec shader_spec;
@@ -5460,6 +5478,12 @@ bool GLES2DecoderImpl::GetHelper(
params[0] = group_->bind_generates_resource() ? 1 : 0;
}
return true;
+ case GL_MAX_DUAL_SOURCE_DRAW_BUFFERS:
+ *num_written = 1;
+ if (params) {
+ params[0] = group_->max_dual_source_draw_buffers();
+ }
+ return true;
default:
if (pname >= GL_DRAW_BUFFER0_ARB &&
pname < GL_DRAW_BUFFER0_ARB + group_->max_draw_buffers()) {
@@ -5640,6 +5664,114 @@ error::Error GLES2DecoderImpl::HandleBindAttribLocationBucket(
return error::kNoError;
}
+error::Error GLES2DecoderImpl::DoBindFragDataLocation(GLuint program_id,
+ GLuint colorName,
+ const char* name) {
+ if (!unsafe_es3_apis_enabled())
+ return error::kUnknownCommand;
+
+ const char kFunctionName[] = "glBindFragDataLocationEXT";
+ if (!StringIsValidForGLES(name)) {
+ LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "Invalid character");
+ return error::kNoError;
+ }
+ if (ProgramManager::IsInvalidPrefix(name, strlen(name))) {
+ LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, "reserved prefix");
+ return error::kNoError;
+ }
+ if (colorName >= group_->max_draw_buffers()) {
+ LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName,
+ "colorName out of range");
+ return error::kNoError;
+ }
+ Program* program = GetProgramInfoNotShader(program_id, kFunctionName);
+ if (!program) {
+ return error::kNoError;
+ }
+ DCHECK(!IsWebGLContext());
+ // Note: the name is passed directly, since names are never hashed for
+ // non-WebGL context. Also the
+ // potential built-in names can not be controlled by the client, since they
+ // will be overridden if
+ // used.
+ glBindFragDataLocation(program->service_id(), colorName, name);
+ return error::kNoError;
+}
+error::Error GLES2DecoderImpl::HandleBindFragDataLocationEXTBucket(
+ uint32 immediate_data_size,
+ const void* cmd_data) {
+ const gles2::cmds::BindFragDataLocationEXTBucket& c =
+ *static_cast<const gles2::cmds::BindFragDataLocationEXTBucket*>(cmd_data);
+ GLuint program = static_cast<GLuint>(c.program);
+ GLuint colorNumber = static_cast<GLint>(c.colorNumber);
+ Bucket* bucket = GetBucket(c.name_bucket_id);
+ if (!bucket || bucket->size() == 0) {
+ return error::kInvalidArguments;
+ }
+ std::string name_str;
+ if (!bucket->GetAsString(&name_str)) {
+ return error::kInvalidArguments;
+ }
+ return DoBindFragDataLocation(program, colorNumber, name_str.c_str());
+}
+
+error::Error GLES2DecoderImpl::DoBindFragDataLocationIndexed(GLuint program_id,
+ GLuint colorName,
+ GLuint index,
+ const char* name) {
+ if (!unsafe_es3_apis_enabled())
+ return error::kUnknownCommand;
+
+ const char kFunctionName[] = "glBindFragDataLocationIndexEXT";
+ if (!StringIsValidForGLES(name)) {
+ LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "Invalid character");
+ return error::kNoError;
+ }
+ if (ProgramManager::IsInvalidPrefix(name, strlen(name))) {
+ LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, "reserved prefix");
+ return error::kNoError;
+ }
+ if ((index == 0 && colorName >= group_->max_draw_buffers()) ||
+ (index == 1 && colorName >= group_->max_dual_source_draw_buffers())) {
+ LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName,
+ "colorName out of range for the color index");
+ return error::kNoError;
+ }
+ Program* program = GetProgramInfoNotShader(program_id, kFunctionName);
+ if (!program) {
+ return error::kNoError;
+ }
+ DCHECK(!IsWebGLContext());
+ // Note: the name is passed directly, since names are never hashed for
+ // non-WebGL context. Also the
+ // potential built-in names can not be controlled by the client, since they
+ // will be overridden if
+ // used.
+ glBindFragDataLocationIndexed(program->service_id(), colorName, index, name);
+ return error::kNoError;
+}
+
+error::Error GLES2DecoderImpl::HandleBindFragDataLocationIndexedEXTBucket(
+ uint32 immediate_data_size,
+ const void* cmd_data) {
+ const gles2::cmds::BindFragDataLocationIndexedEXTBucket& c =
+ *static_cast<const gles2::cmds::BindFragDataLocationIndexedEXTBucket*>(
+ cmd_data);
+ GLuint program = static_cast<GLuint>(c.program);
+ GLuint colorNumber = static_cast<GLint>(c.colorNumber);
+ GLuint index = static_cast<GLint>(c.index);
+ Bucket* bucket = GetBucket(c.name_bucket_id);
+ if (!bucket || bucket->size() == 0) {
+ return error::kInvalidArguments;
+ }
+ std::string name_str;
+ if (!bucket->GetAsString(&name_str)) {
+ return error::kInvalidArguments;
+ }
+ return DoBindFragDataLocationIndexed(program, colorNumber, index,
+ name_str.c_str());
+}
+
void GLES2DecoderImpl::DoBindUniformLocationCHROMIUM(
GLuint program_id, GLint location, const char* name) {
if (!StringIsValidForGLES(name)) {
@@ -9194,6 +9326,7 @@ error::Error GLES2DecoderImpl::HandleGetUniformIndices(
error::Error GLES2DecoderImpl::GetFragDataLocationHelper(
GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
const std::string& name_str) {
+ const char kFunctionName[] = "glGetFragDataLocation";
GLint* location = GetSharedMemoryAs<GLint*>(
location_shm_id, location_shm_offset, sizeof(GLint));
if (!location) {
@@ -9204,12 +9337,17 @@ error::Error GLES2DecoderImpl::GetFragDataLocationHelper(
if (*location != -1) {
return error::kGenericError;
}
- Program* program = GetProgramInfoNotShader(
- client_id, "glGetFragDataLocation");
+ Program* program = GetProgramInfoNotShader(client_id, kFunctionName);
if (!program) {
return error::kNoError;
}
- *location = glGetFragDataLocation(program->service_id(), name_str.c_str());
+ if (!program->IsValid()) {
+ LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName,
+ "program not linked");
+ return error::kNoError;
+ }
Mark Kilgard 2015/08/28 19:53:24 yes, good to add this link check here
+
+ *location = program->GetFragDataLocation(name_str);
return error::kNoError;
}
@@ -9232,6 +9370,56 @@ error::Error GLES2DecoderImpl::HandleGetFragDataLocation(
c.program, c.location_shm_id, c.location_shm_offset, name_str);
}
+error::Error GLES2DecoderImpl::GetFragDataIndexHelper(
+ GLuint program_id,
+ uint32 index_shm_id,
+ uint32 index_shm_offset,
+ const std::string& name_str) {
+ const char kFunctionName[] = "glGetFragDataIndexEXT";
+ GLint* index =
+ GetSharedMemoryAs<GLint*>(index_shm_id, index_shm_offset, sizeof(GLint));
+ if (!index) {
+ return error::kOutOfBounds;
+ }
+ // Require the client to init this incase the context is lost and we are no
+ // longer executing commands.
+ if (*index != -1) {
+ return error::kGenericError;
+ }
+ Program* program = GetProgramInfoNotShader(program_id, kFunctionName);
+ if (!program) {
+ return error::kNoError;
+ }
+ if (!program->IsValid()) {
+ LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName,
+ "program not linked");
+ return error::kNoError;
+ }
+
+ *index = program->GetFragDataIndex(name_str);
+ return error::kNoError;
+}
+
+error::Error GLES2DecoderImpl::HandleGetFragDataIndexEXT(
+ uint32 immediate_data_size,
+ const void* cmd_data) {
+ if (!unsafe_es3_apis_enabled())
+ return error::kUnknownCommand;
+ const gles2::cmds::GetFragDataIndexEXT& c =
+ *static_cast<const gles2::cmds::GetFragDataIndexEXT*>(cmd_data);
+ Bucket* bucket = GetBucket(c.name_bucket_id);
+ if (!bucket) {
+ return error::kInvalidArguments;
+ }
+ std::string name_str;
+ if (!bucket->GetAsString(&name_str)) {
+ return error::kInvalidArguments;
+ }
+ return GetFragDataIndexHelper(c.program, c.index_shm_id, c.index_shm_offset,
+
+ name_str);
+}
+
error::Error GLES2DecoderImpl::HandleGetUniformBlockIndex(
uint32 immediate_data_size, const void* cmd_data) {
if (!unsafe_es3_apis_enabled())

Powered by Google App Engine
This is Rietveld 408576698