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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 1021803003: Merge: gpu: Use GetUniformSetup computed result size. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2311
Patch Set: Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 default: 1625 default:
1626 NOTREACHED(); 1626 NOTREACHED();
1627 break; 1627 break;
1628 } 1628 }
1629 return renderbuffer; 1629 return renderbuffer;
1630 } 1630 }
1631 1631
1632 // Validates the program and location for a glGetUniform call and returns 1632 // Validates the program and location for a glGetUniform call and returns
1633 // a SizeResult setup to receive the result. Returns true if glGetUniform 1633 // a SizeResult setup to receive the result. Returns true if glGetUniform
1634 // should be called. 1634 // should be called.
1635 bool GetUniformSetup( 1635 bool GetUniformSetup(GLuint program,
1636 GLuint program, GLint fake_location, 1636 GLint fake_location,
1637 uint32 shm_id, uint32 shm_offset, 1637 uint32 shm_id,
1638 error::Error* error, GLint* real_location, GLuint* service_id, 1638 uint32 shm_offset,
1639 void** result, GLenum* result_type); 1639 error::Error* error,
1640 GLint* real_location,
1641 GLuint* service_id,
1642 void** result,
1643 GLenum* result_type,
1644 GLsizei* result_size);
1640 1645
1641 void MaybeExitOnContextLost(); 1646 void MaybeExitOnContextLost();
1642 bool WasContextLost() override; 1647 bool WasContextLost() override;
1643 bool WasContextLostByRobustnessExtension() override; 1648 bool WasContextLostByRobustnessExtension() override;
1644 void LoseContext(uint32 reset_status) override; 1649 void LoseContext(uint32 reset_status) override;
1645 1650
1646 #if defined(OS_MACOSX) 1651 #if defined(OS_MACOSX)
1647 void ReleaseIOSurfaceForTexture(GLuint texture_id); 1652 void ReleaseIOSurfaceForTexture(GLuint texture_id);
1648 #endif 1653 #endif
1649 1654
(...skipping 7909 matching lines...) Expand 10 before | Expand all | Expand 10 after
9559 LOCAL_SET_GL_ERROR( 9564 LOCAL_SET_GL_ERROR(
9560 GL_INVALID_VALUE, "glGetVertexAttribPointerv", "index out of range."); 9565 GL_INVALID_VALUE, "glGetVertexAttribPointerv", "index out of range.");
9561 return error::kNoError; 9566 return error::kNoError;
9562 } 9567 }
9563 result->SetNumResults(1); 9568 result->SetNumResults(1);
9564 *result->GetData() = 9569 *result->GetData() =
9565 state_.vertex_attrib_manager->GetVertexAttrib(index)->offset(); 9570 state_.vertex_attrib_manager->GetVertexAttrib(index)->offset();
9566 return error::kNoError; 9571 return error::kNoError;
9567 } 9572 }
9568 9573
9569 bool GLES2DecoderImpl::GetUniformSetup( 9574 bool GLES2DecoderImpl::GetUniformSetup(GLuint program_id,
9570 GLuint program_id, GLint fake_location, 9575 GLint fake_location,
9571 uint32 shm_id, uint32 shm_offset, 9576 uint32 shm_id,
9572 error::Error* error, GLint* real_location, 9577 uint32 shm_offset,
9573 GLuint* service_id, void** result_pointer, GLenum* result_type) { 9578 error::Error* error,
9579 GLint* real_location,
9580 GLuint* service_id,
9581 void** result_pointer,
9582 GLenum* result_type,
9583 GLsizei* result_size) {
9574 DCHECK(error); 9584 DCHECK(error);
9575 DCHECK(service_id); 9585 DCHECK(service_id);
9576 DCHECK(result_pointer); 9586 DCHECK(result_pointer);
9577 DCHECK(result_type); 9587 DCHECK(result_type);
9578 DCHECK(real_location); 9588 DCHECK(real_location);
9579 *error = error::kNoError; 9589 *error = error::kNoError;
9580 // Make sure we have enough room for the result on failure. 9590 // Make sure we have enough room for the result on failure.
9581 SizedResult<GLint>* result; 9591 SizedResult<GLint>* result;
9582 result = GetSharedMemoryAs<SizedResult<GLint>*>( 9592 result = GetSharedMemoryAs<SizedResult<GLint>*>(
9583 shm_id, shm_offset, SizedResult<GLint>::ComputeSize(0)); 9593 shm_id, shm_offset, SizedResult<GLint>::ComputeSize(0));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
9615 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetUniform", "unknown type"); 9625 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetUniform", "unknown type");
9616 return false; 9626 return false;
9617 } 9627 }
9618 result = GetSharedMemoryAs<SizedResult<GLint>*>( 9628 result = GetSharedMemoryAs<SizedResult<GLint>*>(
9619 shm_id, shm_offset, SizedResult<GLint>::ComputeSizeFromBytes(size)); 9629 shm_id, shm_offset, SizedResult<GLint>::ComputeSizeFromBytes(size));
9620 if (!result) { 9630 if (!result) {
9621 *error = error::kOutOfBounds; 9631 *error = error::kOutOfBounds;
9622 return false; 9632 return false;
9623 } 9633 }
9624 result->size = size; 9634 result->size = size;
9635 *result_size = size;
9625 *result_type = type; 9636 *result_type = type;
9626 return true; 9637 return true;
9627 } 9638 }
9628 9639
9629 error::Error GLES2DecoderImpl::HandleGetUniformiv(uint32 immediate_data_size, 9640 error::Error GLES2DecoderImpl::HandleGetUniformiv(uint32 immediate_data_size,
9630 const void* cmd_data) { 9641 const void* cmd_data) {
9631 const gles2::cmds::GetUniformiv& c = 9642 const gles2::cmds::GetUniformiv& c =
9632 *static_cast<const gles2::cmds::GetUniformiv*>(cmd_data); 9643 *static_cast<const gles2::cmds::GetUniformiv*>(cmd_data);
9633 GLuint program = c.program; 9644 GLuint program = c.program;
9634 GLint fake_location = c.location; 9645 GLint fake_location = c.location;
9635 GLuint service_id; 9646 GLuint service_id;
9636 GLenum result_type; 9647 GLenum result_type;
9648 GLsizei result_size;
9637 GLint real_location = -1; 9649 GLint real_location = -1;
9638 Error error; 9650 Error error;
9639 void* result; 9651 void* result;
9640 if (GetUniformSetup( 9652 if (GetUniformSetup(program, fake_location, c.params_shm_id,
9641 program, fake_location, c.params_shm_id, c.params_shm_offset, 9653 c.params_shm_offset, &error, &real_location, &service_id,
9642 &error, &real_location, &service_id, &result, &result_type)) { 9654 &result, &result_type, &result_size)) {
9643 glGetUniformiv( 9655 glGetUniformiv(
9644 service_id, real_location, 9656 service_id, real_location,
9645 static_cast<cmds::GetUniformiv::Result*>(result)->GetData()); 9657 static_cast<cmds::GetUniformiv::Result*>(result)->GetData());
9646 } 9658 }
9647 return error; 9659 return error;
9648 } 9660 }
9649 9661
9650 error::Error GLES2DecoderImpl::HandleGetUniformfv(uint32 immediate_data_size, 9662 error::Error GLES2DecoderImpl::HandleGetUniformfv(uint32 immediate_data_size,
9651 const void* cmd_data) { 9663 const void* cmd_data) {
9652 const gles2::cmds::GetUniformfv& c = 9664 const gles2::cmds::GetUniformfv& c =
9653 *static_cast<const gles2::cmds::GetUniformfv*>(cmd_data); 9665 *static_cast<const gles2::cmds::GetUniformfv*>(cmd_data);
9654 GLuint program = c.program; 9666 GLuint program = c.program;
9655 GLint fake_location = c.location; 9667 GLint fake_location = c.location;
9656 GLuint service_id; 9668 GLuint service_id;
9657 GLint real_location = -1; 9669 GLint real_location = -1;
9658 Error error; 9670 Error error;
9659 typedef cmds::GetUniformfv::Result Result; 9671 typedef cmds::GetUniformfv::Result Result;
9660 Result* result; 9672 Result* result;
9661 GLenum result_type; 9673 GLenum result_type;
9662 if (GetUniformSetup( 9674 GLsizei result_size;
9663 program, fake_location, c.params_shm_id, c.params_shm_offset, 9675 if (GetUniformSetup(program, fake_location, c.params_shm_id,
9664 &error, &real_location, &service_id, 9676 c.params_shm_offset, &error, &real_location, &service_id,
9665 reinterpret_cast<void**>(&result), &result_type)) { 9677 reinterpret_cast<void**>(&result), &result_type,
9678 &result_size)) {
9666 if (result_type == GL_BOOL || result_type == GL_BOOL_VEC2 || 9679 if (result_type == GL_BOOL || result_type == GL_BOOL_VEC2 ||
9667 result_type == GL_BOOL_VEC3 || result_type == GL_BOOL_VEC4) { 9680 result_type == GL_BOOL_VEC3 || result_type == GL_BOOL_VEC4) {
9668 GLsizei num_values = result->GetNumResults(); 9681 GLsizei num_values = result_size / sizeof(Result::Type);
9669 scoped_ptr<GLint[]> temp(new GLint[num_values]); 9682 scoped_ptr<GLint[]> temp(new GLint[num_values]);
9670 glGetUniformiv(service_id, real_location, temp.get()); 9683 glGetUniformiv(service_id, real_location, temp.get());
9671 GLfloat* dst = result->GetData(); 9684 GLfloat* dst = result->GetData();
9672 for (GLsizei ii = 0; ii < num_values; ++ii) { 9685 for (GLsizei ii = 0; ii < num_values; ++ii) {
9673 dst[ii] = (temp[ii] != 0); 9686 dst[ii] = (temp[ii] != 0);
9674 } 9687 }
9675 } else { 9688 } else {
9676 glGetUniformfv(service_id, real_location, result->GetData()); 9689 glGetUniformfv(service_id, real_location, result->GetData());
9677 } 9690 }
9678 } 9691 }
(...skipping 2440 matching lines...) Expand 10 before | Expand all | Expand 10 after
12119 } 12132 }
12120 } 12133 }
12121 12134
12122 // Include the auto-generated part of this file. We split this because it means 12135 // Include the auto-generated part of this file. We split this because it means
12123 // we can easily edit the non-auto generated parts right here in this file 12136 // we can easily edit the non-auto generated parts right here in this file
12124 // instead of having to edit some template or the code generator. 12137 // instead of having to edit some template or the code generator.
12125 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 12138 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
12126 12139
12127 } // namespace gles2 12140 } // namespace gles2
12128 } // namespace gpu 12141 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698