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

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

Issue 1016193003: gpu: Use GetUniformSetup computed result size. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 default: 1634 default:
1635 NOTREACHED(); 1635 NOTREACHED();
1636 break; 1636 break;
1637 } 1637 }
1638 return renderbuffer; 1638 return renderbuffer;
1639 } 1639 }
1640 1640
1641 // Validates the program and location for a glGetUniform call and returns 1641 // Validates the program and location for a glGetUniform call and returns
1642 // a SizeResult setup to receive the result. Returns true if glGetUniform 1642 // a SizeResult setup to receive the result. Returns true if glGetUniform
1643 // should be called. 1643 // should be called.
1644 bool GetUniformSetup( 1644 bool GetUniformSetup(GLuint program,
1645 GLuint program, GLint fake_location, 1645 GLint fake_location,
1646 uint32 shm_id, uint32 shm_offset, 1646 uint32 shm_id,
1647 error::Error* error, GLint* real_location, GLuint* service_id, 1647 uint32 shm_offset,
1648 void** result, GLenum* result_type); 1648 error::Error* error,
1649 GLint* real_location,
1650 GLuint* service_id,
1651 void** result,
1652 GLenum* result_type,
1653 GLsizei* result_size);
1649 1654
1650 void MaybeExitOnContextLost(); 1655 void MaybeExitOnContextLost();
1651 bool WasContextLost() override; 1656 bool WasContextLost() override;
1652 bool WasContextLostByRobustnessExtension() override; 1657 bool WasContextLostByRobustnessExtension() override;
1653 void LoseContext(uint32 reset_status) override; 1658 void LoseContext(uint32 reset_status) override;
1654 1659
1655 #if defined(OS_MACOSX) 1660 #if defined(OS_MACOSX)
1656 void ReleaseIOSurfaceForTexture(GLuint texture_id); 1661 void ReleaseIOSurfaceForTexture(GLuint texture_id);
1657 #endif 1662 #endif
1658 1663
(...skipping 7936 matching lines...) Expand 10 before | Expand all | Expand 10 after
9595 LOCAL_SET_GL_ERROR( 9600 LOCAL_SET_GL_ERROR(
9596 GL_INVALID_VALUE, "glGetVertexAttribPointerv", "index out of range."); 9601 GL_INVALID_VALUE, "glGetVertexAttribPointerv", "index out of range.");
9597 return error::kNoError; 9602 return error::kNoError;
9598 } 9603 }
9599 result->SetNumResults(1); 9604 result->SetNumResults(1);
9600 *result->GetData() = 9605 *result->GetData() =
9601 state_.vertex_attrib_manager->GetVertexAttrib(index)->offset(); 9606 state_.vertex_attrib_manager->GetVertexAttrib(index)->offset();
9602 return error::kNoError; 9607 return error::kNoError;
9603 } 9608 }
9604 9609
9605 bool GLES2DecoderImpl::GetUniformSetup( 9610 bool GLES2DecoderImpl::GetUniformSetup(GLuint program_id,
9606 GLuint program_id, GLint fake_location, 9611 GLint fake_location,
9607 uint32 shm_id, uint32 shm_offset, 9612 uint32 shm_id,
9608 error::Error* error, GLint* real_location, 9613 uint32 shm_offset,
9609 GLuint* service_id, void** result_pointer, GLenum* result_type) { 9614 error::Error* error,
9615 GLint* real_location,
9616 GLuint* service_id,
9617 void** result_pointer,
9618 GLenum* result_type,
9619 GLsizei* result_size) {
9610 DCHECK(error); 9620 DCHECK(error);
9611 DCHECK(service_id); 9621 DCHECK(service_id);
9612 DCHECK(result_pointer); 9622 DCHECK(result_pointer);
9613 DCHECK(result_type); 9623 DCHECK(result_type);
9614 DCHECK(real_location); 9624 DCHECK(real_location);
9615 *error = error::kNoError; 9625 *error = error::kNoError;
9616 // Make sure we have enough room for the result on failure. 9626 // Make sure we have enough room for the result on failure.
9617 SizedResult<GLint>* result; 9627 SizedResult<GLint>* result;
9618 result = GetSharedMemoryAs<SizedResult<GLint>*>( 9628 result = GetSharedMemoryAs<SizedResult<GLint>*>(
9619 shm_id, shm_offset, SizedResult<GLint>::ComputeSize(0)); 9629 shm_id, shm_offset, SizedResult<GLint>::ComputeSize(0));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
9651 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetUniform", "unknown type"); 9661 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetUniform", "unknown type");
9652 return false; 9662 return false;
9653 } 9663 }
9654 result = GetSharedMemoryAs<SizedResult<GLint>*>( 9664 result = GetSharedMemoryAs<SizedResult<GLint>*>(
9655 shm_id, shm_offset, SizedResult<GLint>::ComputeSizeFromBytes(size)); 9665 shm_id, shm_offset, SizedResult<GLint>::ComputeSizeFromBytes(size));
9656 if (!result) { 9666 if (!result) {
9657 *error = error::kOutOfBounds; 9667 *error = error::kOutOfBounds;
9658 return false; 9668 return false;
9659 } 9669 }
9660 result->size = size; 9670 result->size = size;
9671 *result_size = size;
9661 *result_type = type; 9672 *result_type = type;
9662 return true; 9673 return true;
9663 } 9674 }
9664 9675
9665 error::Error GLES2DecoderImpl::HandleGetUniformiv(uint32 immediate_data_size, 9676 error::Error GLES2DecoderImpl::HandleGetUniformiv(uint32 immediate_data_size,
9666 const void* cmd_data) { 9677 const void* cmd_data) {
9667 const gles2::cmds::GetUniformiv& c = 9678 const gles2::cmds::GetUniformiv& c =
9668 *static_cast<const gles2::cmds::GetUniformiv*>(cmd_data); 9679 *static_cast<const gles2::cmds::GetUniformiv*>(cmd_data);
9669 GLuint program = c.program; 9680 GLuint program = c.program;
9670 GLint fake_location = c.location; 9681 GLint fake_location = c.location;
9671 GLuint service_id; 9682 GLuint service_id;
9672 GLenum result_type; 9683 GLenum result_type;
9684 GLsizei result_size;
9673 GLint real_location = -1; 9685 GLint real_location = -1;
9674 Error error; 9686 Error error;
9675 void* result; 9687 void* result;
9676 if (GetUniformSetup( 9688 if (GetUniformSetup(program, fake_location, c.params_shm_id,
9677 program, fake_location, c.params_shm_id, c.params_shm_offset, 9689 c.params_shm_offset, &error, &real_location, &service_id,
9678 &error, &real_location, &service_id, &result, &result_type)) { 9690 &result, &result_type, &result_size)) {
9679 glGetUniformiv( 9691 glGetUniformiv(
9680 service_id, real_location, 9692 service_id, real_location,
9681 static_cast<cmds::GetUniformiv::Result*>(result)->GetData()); 9693 static_cast<cmds::GetUniformiv::Result*>(result)->GetData());
9682 } 9694 }
9683 return error; 9695 return error;
9684 } 9696 }
9685 9697
9686 error::Error GLES2DecoderImpl::HandleGetUniformfv(uint32 immediate_data_size, 9698 error::Error GLES2DecoderImpl::HandleGetUniformfv(uint32 immediate_data_size,
9687 const void* cmd_data) { 9699 const void* cmd_data) {
9688 const gles2::cmds::GetUniformfv& c = 9700 const gles2::cmds::GetUniformfv& c =
9689 *static_cast<const gles2::cmds::GetUniformfv*>(cmd_data); 9701 *static_cast<const gles2::cmds::GetUniformfv*>(cmd_data);
9690 GLuint program = c.program; 9702 GLuint program = c.program;
9691 GLint fake_location = c.location; 9703 GLint fake_location = c.location;
9692 GLuint service_id; 9704 GLuint service_id;
9693 GLint real_location = -1; 9705 GLint real_location = -1;
9694 Error error; 9706 Error error;
9695 typedef cmds::GetUniformfv::Result Result; 9707 typedef cmds::GetUniformfv::Result Result;
9696 Result* result; 9708 Result* result;
9697 GLenum result_type; 9709 GLenum result_type;
9698 if (GetUniformSetup( 9710 GLsizei result_size;
9699 program, fake_location, c.params_shm_id, c.params_shm_offset, 9711 if (GetUniformSetup(program, fake_location, c.params_shm_id,
9700 &error, &real_location, &service_id, 9712 c.params_shm_offset, &error, &real_location, &service_id,
9701 reinterpret_cast<void**>(&result), &result_type)) { 9713 reinterpret_cast<void**>(&result), &result_type,
9714 &result_size)) {
9702 if (result_type == GL_BOOL || result_type == GL_BOOL_VEC2 || 9715 if (result_type == GL_BOOL || result_type == GL_BOOL_VEC2 ||
9703 result_type == GL_BOOL_VEC3 || result_type == GL_BOOL_VEC4) { 9716 result_type == GL_BOOL_VEC3 || result_type == GL_BOOL_VEC4) {
9704 GLsizei num_values = result->GetNumResults(); 9717 GLsizei num_values = result_size / sizeof(GLfloat);
piman 2015/03/19 23:00:06 nit: result_size / sizeof(Result::Type);
9705 scoped_ptr<GLint[]> temp(new GLint[num_values]); 9718 scoped_ptr<GLint[]> temp(new GLint[num_values]);
9706 glGetUniformiv(service_id, real_location, temp.get()); 9719 glGetUniformiv(service_id, real_location, temp.get());
9707 GLfloat* dst = result->GetData(); 9720 GLfloat* dst = result->GetData();
9708 for (GLsizei ii = 0; ii < num_values; ++ii) { 9721 for (GLsizei ii = 0; ii < num_values; ++ii) {
9709 dst[ii] = (temp[ii] != 0); 9722 dst[ii] = (temp[ii] != 0);
9710 } 9723 }
9711 } else { 9724 } else {
9712 glGetUniformfv(service_id, real_location, result->GetData()); 9725 glGetUniformfv(service_id, real_location, result->GetData());
9713 } 9726 }
9714 } 9727 }
(...skipping 2703 matching lines...) Expand 10 before | Expand all | Expand 10 after
12418 } 12431 }
12419 } 12432 }
12420 12433
12421 // Include the auto-generated part of this file. We split this because it means 12434 // Include the auto-generated part of this file. We split this because it means
12422 // we can easily edit the non-auto generated parts right here in this file 12435 // we can easily edit the non-auto generated parts right here in this file
12423 // instead of having to edit some template or the code generator. 12436 // instead of having to edit some template or the code generator.
12424 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 12437 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
12425 12438
12426 } // namespace gles2 12439 } // namespace gles2
12427 } // namespace gpu 12440 } // 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