summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authoralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-28 17:21:38 +0000
committeralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-28 17:21:38 +0000
commit7cea56d943924d0c2196bdf4049f592b6182992c (patch)
tree7582dd4f41b8ee98d01f664688ef24ad9989fe25 /gpu
parent288f31156953cd8598b5da317bc376dfba689e7e (diff)
downloadchromium_src-7cea56d943924d0c2196bdf4049f592b6182992c.zip
chromium_src-7cea56d943924d0c2196bdf4049f592b6182992c.tar.gz
chromium_src-7cea56d943924d0c2196bdf4049f592b6182992c.tar.bz2
Added shader type to shader info.
Review URL: http://codereview.chromium.org/1696012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45823 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc11
-rw-r--r--gpu/command_buffer/service/shader_manager.cc6
-rw-r--r--gpu/command_buffer/service/shader_manager.h19
-rw-r--r--gpu/command_buffer/service/shader_manager_unittest.cc7
4 files changed, 30 insertions, 13 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index d85310e..05e5968 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -512,8 +512,10 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
}
// Creates a ShaderInfo for the given shader.
- void CreateShaderInfo(GLuint client_id, GLuint service_id) {
- shader_manager()->CreateShaderInfo(client_id, service_id);
+ void CreateShaderInfo(GLuint client_id,
+ GLuint service_id,
+ GLenum shader_type) {
+ shader_manager()->CreateShaderInfo(client_id, service_id, shader_type);
}
// Gets the shader info for the given shader. Returns NULL if none exists.
@@ -1705,7 +1707,7 @@ bool GLES2DecoderImpl::CreateShaderHelper(GLenum type, GLuint client_id) {
}
GLuint service_id = glCreateShader(type);
if (service_id != 0) {
- CreateShaderInfo(client_id, service_id);
+ CreateShaderInfo(client_id, service_id, type);
}
return true;
}
@@ -2506,7 +2508,8 @@ void GLES2DecoderImpl::DoCompileShader(GLuint client_id) {
#if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
#if defined(GLES2_GPU_SERVICE_TRANSLATE_SHADER)
int dbg_options = 0;
- EShLanguage language = EShLangVertex;
+ EShLanguage language = info->shader_type() == GL_VERTEX_SHADER ?
+ EShLangVertex : EShLangFragment;
TBuiltInResource resources;
// TODO(alokp): Ask gman how to get appropriate values.
resources.maxVertexAttribs = 8;
diff --git a/gpu/command_buffer/service/shader_manager.cc b/gpu/command_buffer/service/shader_manager.cc
index 53cb689..36a7b1a 100644
--- a/gpu/command_buffer/service/shader_manager.cc
+++ b/gpu/command_buffer/service/shader_manager.cc
@@ -8,10 +8,12 @@
namespace gpu {
namespace gles2 {
-void ShaderManager::CreateShaderInfo(GLuint client_id, GLuint service_id) {
+void ShaderManager::CreateShaderInfo(GLuint client_id,
+ GLuint service_id,
+ GLenum shader_type) {
std::pair<ShaderInfoMap::iterator, bool> result =
shader_infos_.insert(std::make_pair(
- client_id, ShaderInfo::Ref(new ShaderInfo(service_id))));
+ client_id, ShaderInfo::Ref(new ShaderInfo(service_id, shader_type))));
DCHECK(result.second);
}
diff --git a/gpu/command_buffer/service/shader_manager.h b/gpu/command_buffer/service/shader_manager.h
index d911044..caf41b4 100644
--- a/gpu/command_buffer/service/shader_manager.h
+++ b/gpu/command_buffer/service/shader_manager.h
@@ -28,8 +28,9 @@ class ShaderManager {
public:
typedef scoped_refptr<ShaderInfo> Ref;
- explicit ShaderInfo(GLuint service_id)
- : service_id_(service_id) {
+ explicit ShaderInfo(GLuint service_id, GLenum shader_type)
+ : service_id_(service_id),
+ shader_type_(shader_type) {
}
void Update(const std::string& source) {
@@ -40,11 +41,15 @@ class ShaderManager {
return service_id_;
}
- const std::string& source() {
+ GLenum shader_type() const {
+ return shader_type_;
+ }
+
+ const std::string& source() const {
return source_;
}
- bool IsDeleted() {
+ bool IsDeleted() const {
return service_id_ == 0;
}
@@ -59,6 +64,8 @@ class ShaderManager {
// The shader this ShaderInfo is tracking.
GLuint service_id_;
+ // Type of shader - GL_VERTEX_SHADER or GL_FRAGMENT_SHADER.
+ GLenum shader_type_;
// The shader source as passed to glShaderSource.
std::string source_;
@@ -68,7 +75,9 @@ class ShaderManager {
}
// Creates a shader info for the given shader ID.
- void CreateShaderInfo(GLuint client_id, GLuint service_id);
+ void CreateShaderInfo(GLuint client_id,
+ GLuint service_id,
+ GLenum shader_type);
// Gets an existing shader info for the given shader ID. Returns NULL if none
// exists.
diff --git a/gpu/command_buffer/service/shader_manager_unittest.cc b/gpu/command_buffer/service/shader_manager_unittest.cc
index c30d4c6..70d733b 100644
--- a/gpu/command_buffer/service/shader_manager_unittest.cc
+++ b/gpu/command_buffer/service/shader_manager_unittest.cc
@@ -26,15 +26,18 @@ class ShaderManagerTest : public testing::Test {
TEST_F(ShaderManagerTest, Basic) {
const GLuint kClient1Id = 1;
const GLuint kService1Id = 11;
+ const GLenum kShader1Type = GL_VERTEX_SHADER;
const std::string kClient1Source("hello world");
const GLuint kClient2Id = 2;
// Check we can create shader.
- manager_.CreateShaderInfo(kClient1Id, kService1Id);
+ manager_.CreateShaderInfo(kClient1Id, kService1Id, kShader1Type);
// Check shader got created.
ShaderManager::ShaderInfo* info1 = manager_.GetShaderInfo(kClient1Id);
ASSERT_TRUE(info1 != NULL);
EXPECT_EQ(kService1Id, info1->service_id());
- // Check we and set its source.
+ // Check if the shader has correct type.
+ EXPECT_EQ(kShader1Type, info1->shader_type());
+ // Check we can set its source.
info1->Update(kClient1Source);
EXPECT_STREQ(kClient1Source.c_str(), info1->source().c_str());
// Check we get nothing for a non-existent shader.