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

Unified Diff: gpu/command_buffer/tests/gl_gpu_memory_buffer_unittest.cc

Issue 2786103003: Add half-float IOSurface GpuMemoryBuffer support (Closed)
Patch Set: Review feedback Created 3 years, 8 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
« no previous file with comments | « gpu/command_buffer/common/gpu_memory_buffer_support.cc ('k') | gpu/ipc/client/command_buffer_proxy_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/tests/gl_gpu_memory_buffer_unittest.cc
diff --git a/gpu/command_buffer/tests/gl_gpu_memory_buffer_unittest.cc b/gpu/command_buffer/tests/gl_gpu_memory_buffer_unittest.cc
index 0d1df1eb8d0a60a1de18df8cfb3603ec52c4039b..3429111ba1587f3fecedd591772d71a74c84f489 100644
--- a/gpu/command_buffer/tests/gl_gpu_memory_buffer_unittest.cc
+++ b/gpu/command_buffer/tests/gl_gpu_memory_buffer_unittest.cc
@@ -21,6 +21,7 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/gpu_memory_buffer.h"
+#include "ui/gfx/half_float.h"
#include "ui/gl/gl_image.h"
using testing::_;
@@ -116,6 +117,22 @@ void SetRow(gfx::BufferFormat format,
buffer[i + 3] = pixel[3];
}
return;
+ case gfx::BufferFormat::RGBA_F16: {
+ float float_pixel[4] = {
+ pixel[0] / 255.f, pixel[1] / 255.f, pixel[2] / 255.f,
+ pixel[3] / 255.f,
+ };
+ uint16_t half_float_pixel[4];
+ gfx::FloatToHalfFloat(float_pixel, half_float_pixel, 4);
+ uint16_t* half_float_buffer = reinterpret_cast<uint16_t*>(buffer);
+ for (int i = 0; i < width * 4; i += 4) {
+ half_float_buffer[i + 0] = half_float_pixel[0];
+ half_float_buffer[i + 1] = half_float_pixel[1];
+ half_float_buffer[i + 2] = half_float_pixel[2];
+ half_float_buffer[i + 3] = half_float_pixel[3];
+ }
+ return;
+ }
case gfx::BufferFormat::ATC:
case gfx::BufferFormat::ATCIA:
case gfx::BufferFormat::BGRX_8888:
@@ -147,6 +164,8 @@ GLenum InternalFormat(gfx::BufferFormat format) {
return GL_RGBA;
case gfx::BufferFormat::BGRA_8888:
return GL_BGRA_EXT;
+ case gfx::BufferFormat::RGBA_F16:
+ return GL_RGBA;
case gfx::BufferFormat::ATC:
case gfx::BufferFormat::ATCIA:
case gfx::BufferFormat::BGRX_8888:
@@ -255,7 +274,8 @@ INSTANTIATE_TEST_CASE_P(GpuMemoryBufferTests,
gfx::BufferFormat::BGR_565,
gfx::BufferFormat::RGBA_4444,
gfx::BufferFormat::RGBA_8888,
- gfx::BufferFormat::BGRA_8888));
+ gfx::BufferFormat::BGRA_8888,
+ gfx::BufferFormat::RGBA_F16));
} // namespace gles2
} // namespace gpu
« no previous file with comments | « gpu/command_buffer/common/gpu_memory_buffer_support.cc ('k') | gpu/ipc/client/command_buffer_proxy_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698