OLD | NEW |
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 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1623 default: | 1623 default: |
1624 NOTREACHED(); | 1624 NOTREACHED(); |
1625 break; | 1625 break; |
1626 } | 1626 } |
1627 return renderbuffer; | 1627 return renderbuffer; |
1628 } | 1628 } |
1629 | 1629 |
1630 // Validates the program and location for a glGetUniform call and returns | 1630 // Validates the program and location for a glGetUniform call and returns |
1631 // a SizeResult setup to receive the result. Returns true if glGetUniform | 1631 // a SizeResult setup to receive the result. Returns true if glGetUniform |
1632 // should be called. | 1632 // should be called. |
1633 bool GetUniformSetup( | 1633 bool GetUniformSetup(GLuint program, |
1634 GLuint program, GLint fake_location, | 1634 GLint fake_location, |
1635 uint32 shm_id, uint32 shm_offset, | 1635 uint32 shm_id, |
1636 error::Error* error, GLint* real_location, GLuint* service_id, | 1636 uint32 shm_offset, |
1637 void** result, GLenum* result_type); | 1637 error::Error* error, |
| 1638 GLint* real_location, |
| 1639 GLuint* service_id, |
| 1640 void** result, |
| 1641 GLenum* result_type, |
| 1642 GLsizei* result_size); |
1638 | 1643 |
1639 void MaybeExitOnContextLost(); | 1644 void MaybeExitOnContextLost(); |
1640 bool WasContextLost() override; | 1645 bool WasContextLost() override; |
1641 bool WasContextLostByRobustnessExtension() override; | 1646 bool WasContextLostByRobustnessExtension() override; |
1642 void LoseContext(uint32 reset_status) override; | 1647 void LoseContext(uint32 reset_status) override; |
1643 | 1648 |
1644 #if defined(OS_MACOSX) | 1649 #if defined(OS_MACOSX) |
1645 void ReleaseIOSurfaceForTexture(GLuint texture_id); | 1650 void ReleaseIOSurfaceForTexture(GLuint texture_id); |
1646 #endif | 1651 #endif |
1647 | 1652 |
(...skipping 7775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9423 LOCAL_SET_GL_ERROR( | 9428 LOCAL_SET_GL_ERROR( |
9424 GL_INVALID_VALUE, "glGetVertexAttribPointerv", "index out of range."); | 9429 GL_INVALID_VALUE, "glGetVertexAttribPointerv", "index out of range."); |
9425 return error::kNoError; | 9430 return error::kNoError; |
9426 } | 9431 } |
9427 result->SetNumResults(1); | 9432 result->SetNumResults(1); |
9428 *result->GetData() = | 9433 *result->GetData() = |
9429 state_.vertex_attrib_manager->GetVertexAttrib(index)->offset(); | 9434 state_.vertex_attrib_manager->GetVertexAttrib(index)->offset(); |
9430 return error::kNoError; | 9435 return error::kNoError; |
9431 } | 9436 } |
9432 | 9437 |
9433 bool GLES2DecoderImpl::GetUniformSetup( | 9438 bool GLES2DecoderImpl::GetUniformSetup(GLuint program_id, |
9434 GLuint program_id, GLint fake_location, | 9439 GLint fake_location, |
9435 uint32 shm_id, uint32 shm_offset, | 9440 uint32 shm_id, |
9436 error::Error* error, GLint* real_location, | 9441 uint32 shm_offset, |
9437 GLuint* service_id, void** result_pointer, GLenum* result_type) { | 9442 error::Error* error, |
| 9443 GLint* real_location, |
| 9444 GLuint* service_id, |
| 9445 void** result_pointer, |
| 9446 GLenum* result_type, |
| 9447 GLsizei* result_size) { |
9438 DCHECK(error); | 9448 DCHECK(error); |
9439 DCHECK(service_id); | 9449 DCHECK(service_id); |
9440 DCHECK(result_pointer); | 9450 DCHECK(result_pointer); |
9441 DCHECK(result_type); | 9451 DCHECK(result_type); |
9442 DCHECK(real_location); | 9452 DCHECK(real_location); |
9443 *error = error::kNoError; | 9453 *error = error::kNoError; |
9444 // Make sure we have enough room for the result on failure. | 9454 // Make sure we have enough room for the result on failure. |
9445 SizedResult<GLint>* result; | 9455 SizedResult<GLint>* result; |
9446 result = GetSharedMemoryAs<SizedResult<GLint>*>( | 9456 result = GetSharedMemoryAs<SizedResult<GLint>*>( |
9447 shm_id, shm_offset, SizedResult<GLint>::ComputeSize(0)); | 9457 shm_id, shm_offset, SizedResult<GLint>::ComputeSize(0)); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9479 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetUniform", "unknown type"); | 9489 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetUniform", "unknown type"); |
9480 return false; | 9490 return false; |
9481 } | 9491 } |
9482 result = GetSharedMemoryAs<SizedResult<GLint>*>( | 9492 result = GetSharedMemoryAs<SizedResult<GLint>*>( |
9483 shm_id, shm_offset, SizedResult<GLint>::ComputeSizeFromBytes(size)); | 9493 shm_id, shm_offset, SizedResult<GLint>::ComputeSizeFromBytes(size)); |
9484 if (!result) { | 9494 if (!result) { |
9485 *error = error::kOutOfBounds; | 9495 *error = error::kOutOfBounds; |
9486 return false; | 9496 return false; |
9487 } | 9497 } |
9488 result->size = size; | 9498 result->size = size; |
| 9499 *result_size = size; |
9489 *result_type = type; | 9500 *result_type = type; |
9490 return true; | 9501 return true; |
9491 } | 9502 } |
9492 | 9503 |
9493 error::Error GLES2DecoderImpl::HandleGetUniformiv(uint32 immediate_data_size, | 9504 error::Error GLES2DecoderImpl::HandleGetUniformiv(uint32 immediate_data_size, |
9494 const void* cmd_data) { | 9505 const void* cmd_data) { |
9495 const gles2::cmds::GetUniformiv& c = | 9506 const gles2::cmds::GetUniformiv& c = |
9496 *static_cast<const gles2::cmds::GetUniformiv*>(cmd_data); | 9507 *static_cast<const gles2::cmds::GetUniformiv*>(cmd_data); |
9497 GLuint program = c.program; | 9508 GLuint program = c.program; |
9498 GLint fake_location = c.location; | 9509 GLint fake_location = c.location; |
9499 GLuint service_id; | 9510 GLuint service_id; |
9500 GLenum result_type; | 9511 GLenum result_type; |
| 9512 GLsizei result_size; |
9501 GLint real_location = -1; | 9513 GLint real_location = -1; |
9502 Error error; | 9514 Error error; |
9503 void* result; | 9515 void* result; |
9504 if (GetUniformSetup( | 9516 if (GetUniformSetup(program, fake_location, c.params_shm_id, |
9505 program, fake_location, c.params_shm_id, c.params_shm_offset, | 9517 c.params_shm_offset, &error, &real_location, &service_id, |
9506 &error, &real_location, &service_id, &result, &result_type)) { | 9518 &result, &result_type, &result_size)) { |
9507 glGetUniformiv( | 9519 glGetUniformiv( |
9508 service_id, real_location, | 9520 service_id, real_location, |
9509 static_cast<cmds::GetUniformiv::Result*>(result)->GetData()); | 9521 static_cast<cmds::GetUniformiv::Result*>(result)->GetData()); |
9510 } | 9522 } |
9511 return error; | 9523 return error; |
9512 } | 9524 } |
9513 | 9525 |
9514 error::Error GLES2DecoderImpl::HandleGetUniformfv(uint32 immediate_data_size, | 9526 error::Error GLES2DecoderImpl::HandleGetUniformfv(uint32 immediate_data_size, |
9515 const void* cmd_data) { | 9527 const void* cmd_data) { |
9516 const gles2::cmds::GetUniformfv& c = | 9528 const gles2::cmds::GetUniformfv& c = |
9517 *static_cast<const gles2::cmds::GetUniformfv*>(cmd_data); | 9529 *static_cast<const gles2::cmds::GetUniformfv*>(cmd_data); |
9518 GLuint program = c.program; | 9530 GLuint program = c.program; |
9519 GLint fake_location = c.location; | 9531 GLint fake_location = c.location; |
9520 GLuint service_id; | 9532 GLuint service_id; |
9521 GLint real_location = -1; | 9533 GLint real_location = -1; |
9522 Error error; | 9534 Error error; |
9523 typedef cmds::GetUniformfv::Result Result; | 9535 typedef cmds::GetUniformfv::Result Result; |
9524 Result* result; | 9536 Result* result; |
9525 GLenum result_type; | 9537 GLenum result_type; |
9526 if (GetUniformSetup( | 9538 GLsizei result_size; |
9527 program, fake_location, c.params_shm_id, c.params_shm_offset, | 9539 if (GetUniformSetup(program, fake_location, c.params_shm_id, |
9528 &error, &real_location, &service_id, | 9540 c.params_shm_offset, &error, &real_location, &service_id, |
9529 reinterpret_cast<void**>(&result), &result_type)) { | 9541 reinterpret_cast<void**>(&result), &result_type, |
| 9542 &result_size)) { |
9530 if (result_type == GL_BOOL || result_type == GL_BOOL_VEC2 || | 9543 if (result_type == GL_BOOL || result_type == GL_BOOL_VEC2 || |
9531 result_type == GL_BOOL_VEC3 || result_type == GL_BOOL_VEC4) { | 9544 result_type == GL_BOOL_VEC3 || result_type == GL_BOOL_VEC4) { |
9532 GLsizei num_values = result->GetNumResults(); | 9545 GLsizei num_values = result_size / sizeof(Result::Type); |
9533 scoped_ptr<GLint[]> temp(new GLint[num_values]); | 9546 scoped_ptr<GLint[]> temp(new GLint[num_values]); |
9534 glGetUniformiv(service_id, real_location, temp.get()); | 9547 glGetUniformiv(service_id, real_location, temp.get()); |
9535 GLfloat* dst = result->GetData(); | 9548 GLfloat* dst = result->GetData(); |
9536 for (GLsizei ii = 0; ii < num_values; ++ii) { | 9549 for (GLsizei ii = 0; ii < num_values; ++ii) { |
9537 dst[ii] = (temp[ii] != 0); | 9550 dst[ii] = (temp[ii] != 0); |
9538 } | 9551 } |
9539 } else { | 9552 } else { |
9540 glGetUniformfv(service_id, real_location, result->GetData()); | 9553 glGetUniformfv(service_id, real_location, result->GetData()); |
9541 } | 9554 } |
9542 } | 9555 } |
(...skipping 2099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11642 } | 11655 } |
11643 } | 11656 } |
11644 | 11657 |
11645 // Include the auto-generated part of this file. We split this because it means | 11658 // Include the auto-generated part of this file. We split this because it means |
11646 // we can easily edit the non-auto generated parts right here in this file | 11659 // we can easily edit the non-auto generated parts right here in this file |
11647 // instead of having to edit some template or the code generator. | 11660 // instead of having to edit some template or the code generator. |
11648 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 11661 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
11649 | 11662 |
11650 } // namespace gles2 | 11663 } // namespace gles2 |
11651 } // namespace gpu | 11664 } // namespace gpu |
OLD | NEW |