OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <GLES2/gl2.h> |
| 6 #include <GLES2/gl2ext.h> |
| 7 #include <GLES2/gl2extchromium.h> |
| 8 #include <GLES3/gl3.h> |
| 9 #include <stdint.h> |
| 10 |
| 11 #include "gpu/command_buffer/tests/gl_manager.h" |
| 12 #include "gpu/command_buffer/tests/gl_test_utils.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 |
| 16 namespace gpu { |
| 17 |
| 18 class ObjectBindingsTest : public testing::Test { |
| 19 protected: |
| 20 void SetUp() override { |
| 21 GLManager::Options options; |
| 22 options.context_type = gles2::CONTEXT_TYPE_OPENGLES3; |
| 23 gl_.Initialize(options); |
| 24 } |
| 25 |
| 26 void TearDown() override { gl_.Destroy(); } |
| 27 bool IsApplicable() const { return gl_.IsInitialized(); } |
| 28 |
| 29 GLManager gl_; |
| 30 }; |
| 31 |
| 32 TEST_F(ObjectBindingsTest, Buffers) { |
| 33 const std::pair<GLenum, GLenum> buffer_bindings[] = { |
| 34 {GL_ARRAY_BUFFER, GL_ARRAY_BUFFER_BINDING}, |
| 35 {GL_ELEMENT_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER_BINDING}, |
| 36 {GL_PIXEL_PACK_BUFFER, GL_PIXEL_PACK_BUFFER_BINDING}, |
| 37 {GL_PIXEL_UNPACK_BUFFER, GL_PIXEL_UNPACK_BUFFER_BINDING}, |
| 38 {GL_TRANSFORM_FEEDBACK_BUFFER, GL_TRANSFORM_FEEDBACK_BUFFER_BINDING}, |
| 39 {GL_COPY_READ_BUFFER, GL_COPY_READ_BUFFER_BINDING}, |
| 40 {GL_COPY_WRITE_BUFFER, GL_COPY_WRITE_BUFFER_BINDING}, |
| 41 {GL_UNIFORM_BUFFER, GL_UNIFORM_BUFFER_BINDING}, |
| 42 }; |
| 43 |
| 44 for (auto binding : buffer_bindings) { |
| 45 GLuint buffer = 0; |
| 46 glGenBuffers(1, &buffer); |
| 47 glBindBuffer(binding.first, buffer); |
| 48 |
| 49 { |
| 50 GLint result = 0; |
| 51 glGetIntegerv(binding.second, &result); |
| 52 EXPECT_EQ(static_cast<GLuint>(result), buffer); |
| 53 } |
| 54 |
| 55 { |
| 56 GLfloat result = 0; |
| 57 glGetFloatv(binding.second, &result); |
| 58 EXPECT_EQ(static_cast<GLuint>(result), buffer); |
| 59 } |
| 60 |
| 61 glBindBuffer(binding.first, 0); |
| 62 glDeleteBuffers(1, &buffer); |
| 63 } |
| 64 |
| 65 GLTestHelper::CheckGLError("no errors", __LINE__); |
| 66 } |
| 67 |
| 68 TEST_F(ObjectBindingsTest, FramebufferAttachments) { |
| 69 GLuint texture = 0; |
| 70 glGenTextures(1, &texture); |
| 71 glBindTexture(GL_TEXTURE_2D, texture); |
| 72 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 73 nullptr); |
| 74 |
| 75 GLuint renderbuffer = 0; |
| 76 glGenRenderbuffers(1, &renderbuffer); |
| 77 glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer); |
| 78 glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 1, 1); |
| 79 |
| 80 GLuint framebuffer = 0; |
| 81 glGenFramebuffers(1, &framebuffer); |
| 82 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); |
| 83 |
| 84 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 85 texture, 0); |
| 86 { |
| 87 GLint result = 0; |
| 88 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 89 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, |
| 90 &result); |
| 91 EXPECT_EQ(static_cast<GLuint>(result), texture); |
| 92 } |
| 93 |
| 94 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 95 GL_RENDERBUFFER, renderbuffer); |
| 96 { |
| 97 GLint result = 0; |
| 98 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 99 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, |
| 100 &result); |
| 101 EXPECT_EQ(static_cast<GLuint>(result), renderbuffer); |
| 102 } |
| 103 |
| 104 GLTestHelper::CheckGLError("no errors", __LINE__); |
| 105 } |
| 106 |
| 107 } // namespace gpu |
OLD | NEW |