summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/common
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-03 01:11:37 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-03 01:11:37 +0000
commitf7b85373bada6dc2da2ca3b47c38fc25d89dcf2e (patch)
treeb14cdb3fd116c4287f2d61cd0f4e75c91cdf13b4 /gpu/command_buffer/common
parent50d22375941bee74a33e504c78e4355c878c30b9 (diff)
downloadchromium_src-f7b85373bada6dc2da2ca3b47c38fc25d89dcf2e.zip
chromium_src-f7b85373bada6dc2da2ca3b47c38fc25d89dcf2e.tar.gz
chromium_src-f7b85373bada6dc2da2ca3b47c38fc25d89dcf2e.tar.bz2
Implements glGetUniformiv and glGetUniformfv.
TEST=none BUG=none Review URL: http://codereview.chromium.org/566019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37918 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/common')
-rw-r--r--gpu/command_buffer/common/gles2_cmd_format.h12
-rw-r--r--gpu/command_buffer/common/gles2_cmd_utils.cc41
-rw-r--r--gpu/command_buffer/common/gles2_cmd_utils.h2
3 files changed, 55 insertions, 0 deletions
diff --git a/gpu/command_buffer/common/gles2_cmd_format.h b/gpu/command_buffer/common/gles2_cmd_format.h
index 7598318..d6d3beb 100644
--- a/gpu/command_buffer/common/gles2_cmd_format.h
+++ b/gpu/command_buffer/common/gles2_cmd_format.h
@@ -40,10 +40,22 @@ struct SizedResult {
T GetDataAs() {
return static_cast<T>(static_cast<void*>(&data));
}
+
+ // Returns the size of the SizedResult for a given size of result.
+ static size_t GetSize(size_t size_of_result) {
+ return size_of_result + sizeof(uint32); // NOLINT
+ }
+
uint32 size; // in bytes.
int32 data; // this is just here to get an offset.
};
+COMPILE_ASSERT(sizeof(SizedResult) == 8, SizedResult_size_not_8);
+COMPILE_ASSERT(offsetof(SizedResult, size) == 0,
+ OffsetOf_SizedResult_size_not_0);
+COMPILE_ASSERT(offsetof(SizedResult, data) == 4,
+ OffsetOf_SizedResult_data_not_4);
+
#include "gpu/command_buffer/common/gles2_cmd_format_autogen.h"
// These are hand written commands.
diff --git a/gpu/command_buffer/common/gles2_cmd_utils.cc b/gpu/command_buffer/common/gles2_cmd_utils.cc
index 8145315..aac4b84 100644
--- a/gpu/command_buffer/common/gles2_cmd_utils.cc
+++ b/gpu/command_buffer/common/gles2_cmd_utils.cc
@@ -343,6 +343,47 @@ uint32 GLES2Util::ComputeImageDataSize(
return height * row_size;
}
+uint32 GLES2Util::GetGLDataTypeSize(int type) {
+ switch (type) {
+ case GL_FLOAT:
+ return sizeof(GLfloat); // NOLINT
+ case GL_FLOAT_VEC2:
+ return sizeof(GLfloat) * 2; // NOLINT
+ case GL_FLOAT_VEC3:
+ return sizeof(GLfloat) * 3; // NOLINT
+ case GL_FLOAT_VEC4:
+ return sizeof(GLfloat) * 4; // NOLINT
+ case GL_INT:
+ return sizeof(GLint); // NOLINT
+ case GL_INT_VEC2:
+ return sizeof(GLint) * 2; // NOLINT
+ case GL_INT_VEC3:
+ return sizeof(GLint) * 3; // NOLINT
+ case GL_INT_VEC4:
+ return sizeof(GLint) * 4; // NOLINT
+ case GL_BOOL:
+ return sizeof(GLint); // NOLINT
+ case GL_BOOL_VEC2:
+ return sizeof(GLint) * 1; // NOLINT
+ case GL_BOOL_VEC3:
+ return sizeof(GLint) * 2; // NOLINT
+ case GL_BOOL_VEC4:
+ return sizeof(GLint) * 3; // NOLINT
+ case GL_FLOAT_MAT2:
+ return sizeof(GLfloat) * 2 * 2; // NOLINT
+ case GL_FLOAT_MAT3:
+ return sizeof(GLfloat) * 3 * 3; // NOLINT
+ case GL_FLOAT_MAT4:
+ return sizeof(GLfloat) * 4 * 4; // NOLINT
+ case GL_SAMPLER_2D:
+ return sizeof(GLint); // NOLINT
+ case GL_SAMPLER_CUBE:
+ return sizeof(GLint); // NOLINT
+ default:
+ return 0;
+ }
+}
+
} // namespace gles2
} // namespace gpu
diff --git a/gpu/command_buffer/common/gles2_cmd_utils.h b/gpu/command_buffer/common/gles2_cmd_utils.h
index 6a14133..1d2139d 100644
--- a/gpu/command_buffer/common/gles2_cmd_utils.h
+++ b/gpu/command_buffer/common/gles2_cmd_utils.h
@@ -30,6 +30,8 @@ class GLES2Util {
static uint32 ComputeImageDataSize(
int width, int height, int format, int type, int unpack_alignment);
+ static uint32 GetGLDataTypeSize(int type);
+
private:
int num_compressed_texture_formats_;
};