OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/common/constants.h" | 5 #include "gpu/command_buffer/common/constants.h" |
6 #include "gpu/pgl/command_buffer_pepper.h" | 6 #include "gpu/pgl/command_buffer_pepper.h" |
7 | 7 |
8 #ifdef __native_client__ | 8 #ifdef __native_client__ |
9 #include <assert.h> | 9 #include <assert.h> |
10 #define NOTREACHED() assert(0) | 10 #define NOTREACHED() assert(0) |
(...skipping 17 matching lines...) Expand all Loading... |
28 } | 28 } |
29 | 29 |
30 // Not implemented in CommandBufferPepper. | 30 // Not implemented in CommandBufferPepper. |
31 bool CommandBufferPepper::Initialize(int32 size) { | 31 bool CommandBufferPepper::Initialize(int32 size) { |
32 NOTREACHED(); | 32 NOTREACHED(); |
33 return false; | 33 return false; |
34 } | 34 } |
35 | 35 |
36 Buffer CommandBufferPepper::GetRingBuffer() { | 36 Buffer CommandBufferPepper::GetRingBuffer() { |
37 Buffer buffer; | 37 Buffer buffer; |
| 38 #if defined(ENABLE_NEW_NPDEVICE_API) |
| 39 NPDeviceBuffer np_buffer; |
| 40 device_->mapBuffer(npp_, |
| 41 context_, |
| 42 NP3DCommandBufferId, |
| 43 &np_buffer); |
| 44 buffer.ptr = np_buffer.ptr; |
| 45 buffer.size = np_buffer.size; |
| 46 #else |
38 buffer.ptr = context_->commandBuffer; | 47 buffer.ptr = context_->commandBuffer; |
39 buffer.size = context_->commandBufferSize * sizeof(int32); | 48 buffer.size = context_->commandBufferSize * sizeof(int32); |
| 49 #endif |
40 return buffer; | 50 return buffer; |
41 } | 51 } |
42 | 52 |
43 CommandBuffer::State CommandBufferPepper::GetState() { | 53 CommandBuffer::State CommandBufferPepper::GetState() { |
| 54 #if defined(ENABLE_NEW_NPDEVICE_API) |
| 55 int32 output_attribs[] = { |
| 56 NP3DAttrib_CommandBufferSize, 0, |
| 57 NP3DAttrib_GetOffset, 0, |
| 58 NP3DAttrib_PutOffset, 0, |
| 59 NP3DAttrib_Token, 0, |
| 60 NPAttrib_Error, 0, |
| 61 NPAttrib_End |
| 62 }; |
| 63 device_->synchronizeContext(npp_, |
| 64 context_, |
| 65 NPDeviceSynchronizationMode_Immediate, |
| 66 NULL, |
| 67 output_attribs, |
| 68 NULL, |
| 69 NULL); |
| 70 |
| 71 CommandBuffer::State state; |
| 72 state.size = output_attribs[1]; |
| 73 state.get_offset = output_attribs[3]; |
| 74 state.put_offset = output_attribs[5]; |
| 75 state.token = output_attribs[7]; |
| 76 state.error = static_cast<gpu::error::Error>( |
| 77 output_attribs[9]); |
| 78 |
| 79 return state; |
| 80 #else |
44 context_->waitForProgress = false; | 81 context_->waitForProgress = false; |
45 | 82 |
46 if (NPERR_NO_ERROR != device_->flushContext(npp_, context_, NULL, NULL)) | 83 if (NPERR_NO_ERROR != device_->flushContext(npp_, context_, NULL, NULL)) |
47 context_->error = NPDeviceContext3DError_GenericError; | 84 context_->error = NPDeviceContext3DError_GenericError; |
48 | 85 |
49 context_->waitForProgress = true; | 86 context_->waitForProgress = true; |
50 | 87 |
51 return ConvertState(); | 88 return ConvertState(); |
| 89 #endif // ENABLE_NEW_NPDEVICE_API |
52 } | 90 } |
53 | 91 |
54 CommandBuffer::State CommandBufferPepper::Flush(int32 put_offset) { | 92 CommandBuffer::State CommandBufferPepper::Flush(int32 put_offset) { |
| 93 #if defined(ENABLE_NEW_NPDEVICE_API) |
| 94 int32 input_attribs[] = { |
| 95 NP3DAttrib_PutOffset, put_offset, |
| 96 NPAttrib_End |
| 97 }; |
| 98 int32 output_attribs[] = { |
| 99 NP3DAttrib_CommandBufferSize, 0, |
| 100 NP3DAttrib_GetOffset, 0, |
| 101 NP3DAttrib_PutOffset, 0, |
| 102 NP3DAttrib_Token, 0, |
| 103 NPAttrib_Error, 0, |
| 104 NPAttrib_End |
| 105 }; |
| 106 device_->synchronizeContext(npp_, |
| 107 context_, |
| 108 NPDeviceSynchronizationMode_Flush, |
| 109 input_attribs, |
| 110 output_attribs, |
| 111 NULL, |
| 112 NULL); |
| 113 |
| 114 CommandBuffer::State state; |
| 115 state.size = output_attribs[1]; |
| 116 state.get_offset = output_attribs[3]; |
| 117 state.put_offset = output_attribs[5]; |
| 118 state.token = output_attribs[7]; |
| 119 state.error = static_cast<gpu::error::Error>( |
| 120 output_attribs[9]); |
| 121 |
| 122 return state; |
| 123 #else |
55 context_->waitForProgress = true; | 124 context_->waitForProgress = true; |
56 context_->putOffset = put_offset; | 125 context_->putOffset = put_offset; |
57 | 126 |
58 if (NPERR_NO_ERROR != device_->flushContext(npp_, context_, NULL, NULL)) | 127 if (NPERR_NO_ERROR != device_->flushContext(npp_, context_, NULL, NULL)) |
59 context_->error = NPDeviceContext3DError_GenericError; | 128 context_->error = NPDeviceContext3DError_GenericError; |
60 | 129 |
61 return ConvertState(); | 130 return ConvertState(); |
| 131 #endif // ENABLE_NEW_NPDEVICE_API |
62 } | 132 } |
63 | 133 |
64 void CommandBufferPepper::SetGetOffset(int32 get_offset) { | 134 void CommandBufferPepper::SetGetOffset(int32 get_offset) { |
65 // Not implemented by proxy. | 135 // Not implemented by proxy. |
66 NOTREACHED(); | 136 NOTREACHED(); |
67 } | 137 } |
68 | 138 |
69 int32 CommandBufferPepper::CreateTransferBuffer(size_t size) { | 139 int32 CommandBufferPepper::CreateTransferBuffer(size_t size) { |
70 int32 id; | 140 int32 id; |
71 if (NPERR_NO_ERROR != device_->createBuffer(npp_, context_, size, &id)) | 141 if (NPERR_NO_ERROR != device_->createBuffer(npp_, context_, size, &id)) |
(...skipping 21 matching lines...) Expand all Loading... |
93 // Not implemented by proxy. | 163 // Not implemented by proxy. |
94 NOTREACHED(); | 164 NOTREACHED(); |
95 } | 165 } |
96 | 166 |
97 void CommandBufferPepper::SetParseError( | 167 void CommandBufferPepper::SetParseError( |
98 gpu::error::Error error) { | 168 gpu::error::Error error) { |
99 // Not implemented by proxy. | 169 // Not implemented by proxy. |
100 NOTREACHED(); | 170 NOTREACHED(); |
101 } | 171 } |
102 | 172 |
| 173 gpu::error::Error CommandBufferPepper::GetCachedError() { |
| 174 int32 attrib_list[] = { |
| 175 NPAttrib_Error, 0, |
| 176 NPAttrib_End |
| 177 }; |
| 178 device_->synchronizeContext(npp_, |
| 179 context_, |
| 180 NPDeviceSynchronizationMode_Cached, |
| 181 NULL, |
| 182 attrib_list, |
| 183 NULL, |
| 184 NULL); |
| 185 return static_cast<gpu::error::Error>(attrib_list[1]); |
| 186 } |
| 187 |
103 CommandBuffer::State CommandBufferPepper::ConvertState() { | 188 CommandBuffer::State CommandBufferPepper::ConvertState() { |
104 CommandBuffer::State state; | 189 CommandBuffer::State state; |
105 state.size = context_->commandBufferSize; | 190 state.size = context_->commandBufferSize; |
106 state.get_offset = context_->getOffset; | 191 state.get_offset = context_->getOffset; |
107 state.put_offset = context_->putOffset; | 192 state.put_offset = context_->putOffset; |
108 state.token = context_->token; | 193 state.token = context_->token; |
109 state.error = static_cast<gpu::error::Error>( | 194 state.error = static_cast<gpu::error::Error>( |
110 context_->error); | 195 context_->error); |
111 return state; | 196 return state; |
112 } | 197 } |
OLD | NEW |