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

Side by Side Diff: src/shared/ppapi_proxy/command_buffer_nacl.cc

Issue 7631010: NaCl Proxy for graphics3d. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/shared/ppapi_proxy/command_buffer_nacl.h ('k') | src/shared/ppapi_proxy/nacl.scons » ('j') | 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) 2011 The Native Client Authors. All rights reserved. 1 // Copyright (c) 2011 The Native Client 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 "native_client/src/shared/ppapi_proxy/command_buffer_nacl.h" 5 #include "native_client/src/shared/ppapi_proxy/command_buffer_nacl.h"
6 6
7 #include <sys/mman.h> 7 #include <sys/mman.h>
8 #include "gpu/command_buffer/common/logging.h" 8 #include "gpu/command_buffer/common/logging.h"
9 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" 9 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h"
10 #include "native_client/src/shared/ppapi_proxy/utility.h" 10 #include "native_client/src/shared/ppapi_proxy/utility.h"
11 #include "native_client/src/third_party/ppapi/c/ppb_core.h" 11 #include "native_client/src/third_party/ppapi/c/ppb_core.h"
12 12
13 #include "srpcgen/ppb_rpc.h" 13 #include "srpcgen/ppb_rpc.h"
14 14
15 using ppapi_proxy::DebugPrintf; 15 using ppapi_proxy::DebugPrintf;
16 16
17 CommandBufferNacl::CommandBufferNacl(PP_Resource context_3d, 17 CommandBufferNacl::CommandBufferNacl(PP_Resource graphics_3d,
18 const PPB_Core* iface_core) 18 const PPB_Core* iface_core)
19 : context_3d_(context_3d), iface_core_(iface_core) { 19 : graphics_3d_(graphics_3d), iface_core_(iface_core) {
20 iface_core_->AddRefResource(context_3d_); 20 iface_core_->AddRefResource(graphics_3d_);
21 } 21 }
22 22
23 CommandBufferNacl::~CommandBufferNacl() { 23 CommandBufferNacl::~CommandBufferNacl() {
24 iface_core_->ReleaseResource(context_3d_); 24 iface_core_->ReleaseResource(graphics_3d_);
25 } 25 }
26 26
27 bool CommandBufferNacl::Initialize(int32 size) { 27 bool CommandBufferNacl::Initialize(int32 size) {
28 DebugPrintf("CommandBufferNacl::Initialize\n"); 28 DebugPrintf("CommandBufferNacl::Initialize\n");
29 int32_t success; 29 int32_t success;
30 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel(); 30 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel();
31 NaClSrpcError retval = 31 NaClSrpcError retval =
32 PpbGraphics3DRpcClient::PPB_Context3DTrusted_Initialize( 32 PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_InitCommandBuffer(
33 channel, context_3d_, size, &success); 33 channel, graphics_3d_, size, &success);
34 DebugPrintf("CommandBufferNaCl::Initialize returned success=%s\n",
35 (PP_TRUE == success) ? "TRUE" : "FALSE");
34 return NACL_SRPC_RESULT_OK == retval && PP_TRUE == success; 36 return NACL_SRPC_RESULT_OK == retval && PP_TRUE == success;
35 } 37 }
36 38
37 gpu::Buffer CommandBufferNacl::GetRingBuffer() { 39 gpu::Buffer CommandBufferNacl::GetRingBuffer() {
38 DebugPrintf("CommandBufferNacl::GetRingBuffer\n"); 40 DebugPrintf("CommandBufferNacl::GetRingBuffer\n");
39 if (!buffer_.ptr) { 41 if (!buffer_.ptr) {
40 DebugPrintf("CommandBufferNacl::GetRingBuffer: Fetching\n"); 42 DebugPrintf("CommandBufferNacl::GetRingBuffer: Fetching\n");
41 int shm_handle = -1; 43 int shm_handle = -1;
42 int32_t shm_size = 0; 44 int32_t shm_size = 0;
43 45
44 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel(); 46 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel();
45 NaClSrpcError retval = 47 NaClSrpcError retval =
46 PpbGraphics3DRpcClient::PPB_Context3DTrusted_GetRingBuffer( 48 PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_GetRingBuffer(
47 channel, context_3d_, &shm_handle, &shm_size); 49 channel, graphics_3d_, &shm_handle, &shm_size);
48 if (NACL_SRPC_RESULT_OK != retval) { 50 if (NACL_SRPC_RESULT_OK != retval) {
49 shm_handle = -1; 51 shm_handle = -1;
50 } 52 }
51 buffer_ = BufferFromShm(shm_handle, shm_size); 53 buffer_ = BufferFromShm(shm_handle, shm_size);
52 } 54 }
53 55
54 return buffer_; 56 return buffer_;
55 } 57 }
56 58
57 gpu::CommandBuffer::State CommandBufferNacl::GetState() { 59 gpu::CommandBuffer::State CommandBufferNacl::GetState() {
58 DebugPrintf("CommandBufferNacl::GetState\n"); 60 DebugPrintf("CommandBufferNacl::GetState\n");
59 PP_Context3DTrustedState state; 61 PP_Graphics3DTrustedState state;
60 nacl_abi_size_t state_size = static_cast<nacl_abi_size_t>(sizeof(state)); 62 nacl_abi_size_t state_size = static_cast<nacl_abi_size_t>(sizeof(state));
61 63
62 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel(); 64 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel();
63 NaClSrpcError retval = 65 NaClSrpcError retval =
64 PpbGraphics3DRpcClient::PPB_Context3DTrusted_GetState( 66 PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_GetState(
65 channel, context_3d_, &state_size, reinterpret_cast<char*>(&state)); 67 channel, graphics_3d_, &state_size, reinterpret_cast<char*>(&state));
66 if (NACL_SRPC_RESULT_OK != retval 68 if (NACL_SRPC_RESULT_OK != retval
67 || state_size != static_cast<nacl_abi_size_t>(sizeof(state))) { 69 || state_size != static_cast<nacl_abi_size_t>(sizeof(state))) {
68 return ErrorGpuState(); 70 return ErrorGpuState();
69 } 71 }
70 72
71 last_state_ = PpapiToGpuState(state); 73 last_state_ = PpapiToGpuState(state);
72 return last_state_; 74 return last_state_;
73 } 75 }
74 76
75 gpu::CommandBuffer::State CommandBufferNacl::GetLastState() { 77 gpu::CommandBuffer::State CommandBufferNacl::GetLastState() {
76 return last_state_; 78 return last_state_;
77 } 79 }
78 80
79 void CommandBufferNacl::Flush(int32 put_offset) { 81 void CommandBufferNacl::Flush(int32 put_offset) {
80 DebugPrintf("CommandBufferNacl::Flush\n"); 82 DebugPrintf("CommandBufferNacl::Flush\n");
81 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel(); 83 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel();
82 PpbGraphics3DRpcClient::PPB_Context3DTrusted_Flush( 84 PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_Flush(
83 channel, context_3d_, put_offset); 85 channel, graphics_3d_, put_offset);
84 } 86 }
85 87
86 gpu::CommandBuffer::State CommandBufferNacl::FlushSync(int32 put_offset, 88 gpu::CommandBuffer::State CommandBufferNacl::FlushSync(int32 put_offset,
87 int32 last_known_get) { 89 int32 last_known_get) {
88 DebugPrintf("CommandBufferNacl::FlushSync\n"); 90 DebugPrintf("CommandBufferNacl::FlushSync\n");
89 PP_Context3DTrustedState state; 91 PP_Graphics3DTrustedState state;
90 nacl_abi_size_t state_size = static_cast<nacl_abi_size_t>(sizeof(state)); 92 nacl_abi_size_t state_size = static_cast<nacl_abi_size_t>(sizeof(state));
91 93
92 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel(); 94 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel();
93 NaClSrpcError retval = 95 NaClSrpcError retval =
94 PpbGraphics3DRpcClient::PPB_Context3DTrusted_FlushSync( 96 PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_FlushSync(
95 channel, 97 channel,
96 context_3d_, 98 graphics_3d_,
97 put_offset, 99 put_offset,
98 &state_size, 100 &state_size,
99 reinterpret_cast<char*>(&state)); 101 reinterpret_cast<char*>(&state));
100 if (NACL_SRPC_RESULT_OK != retval 102 if (NACL_SRPC_RESULT_OK != retval
101 || state_size != static_cast<nacl_abi_size_t>(sizeof(state))) { 103 || state_size != static_cast<nacl_abi_size_t>(sizeof(state))) {
102 return ErrorGpuState(); 104 return ErrorGpuState();
103 } 105 }
104 106
105 last_state_ = PpapiToGpuState(state); 107 last_state_ = PpapiToGpuState(state);
106 return last_state_; 108 return last_state_;
107 } 109 }
108 110
109 void CommandBufferNacl::SetGetOffset(int32 get_offset) { 111 void CommandBufferNacl::SetGetOffset(int32 get_offset) {
110 DebugPrintf("CommandBufferNacl::SetGetOffset\n"); 112 DebugPrintf("CommandBufferNacl::SetGetOffset\n");
111 // Not implemented by proxy. 113 // Not implemented by proxy.
112 GPU_NOTREACHED(); 114 GPU_NOTREACHED();
113 } 115 }
114 116
115 int32 CommandBufferNacl::CreateTransferBuffer(size_t size, int32 id_request) { 117 int32 CommandBufferNacl::CreateTransferBuffer(size_t size, int32 id_request) {
116 DebugPrintf("CommandBufferNacl::CreateTransferBuffer\n"); 118 DebugPrintf("CommandBufferNacl::CreateTransferBuffer\n");
117 int32_t id; 119 int32_t id;
118 120
119 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel(); 121 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel();
120 NaClSrpcError retval = 122 NaClSrpcError retval =
121 PpbGraphics3DRpcClient::PPB_Context3DTrusted_CreateTransferBuffer( 123 PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_CreateTransferBuffer(
122 channel, context_3d_, size, id_request, &id); 124 channel, graphics_3d_, size, id_request, &id);
123 if (NACL_SRPC_RESULT_OK != retval) 125 if (NACL_SRPC_RESULT_OK != retval)
124 return 0; 126 return 0;
125 127
126 return id; 128 return id;
127 } 129 }
128 130
129 void CommandBufferNacl::DestroyTransferBuffer(int32 id) { 131 void CommandBufferNacl::DestroyTransferBuffer(int32 id) {
130 DebugPrintf("CommandBufferNacl::DestroyTransferBuffer\n"); 132 DebugPrintf("CommandBufferNacl::DestroyTransferBuffer\n");
131 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel(); 133 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel();
132 PpbGraphics3DRpcClient::PPB_Context3DTrusted_DestroyTransferBuffer( 134 PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_DestroyTransferBuffer(
133 channel, context_3d_, id); 135 channel, graphics_3d_, id);
134 } 136 }
135 137
136 gpu::Buffer CommandBufferNacl::GetTransferBuffer(int32 id) { 138 gpu::Buffer CommandBufferNacl::GetTransferBuffer(int32 id) {
137 DebugPrintf("CommandBufferNacl::GetTransferBuffer\n"); 139 DebugPrintf("CommandBufferNacl::GetTransferBuffer\n");
138 int shm_handle; 140 int shm_handle;
139 int32_t shm_size; 141 int32_t shm_size;
140 142
141 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel(); 143 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel();
142 NaClSrpcError retval = 144 NaClSrpcError retval =
143 PpbGraphics3DRpcClient::PPB_Context3DTrusted_GetTransferBuffer( 145 PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_GetTransferBuffer(
144 channel, context_3d_, id, &shm_handle, &shm_size); 146 channel, graphics_3d_, id, &shm_handle, &shm_size);
145 if (NACL_SRPC_RESULT_OK != retval) { 147 if (NACL_SRPC_RESULT_OK != retval) {
146 return BufferFromShm(-1, 0); 148 return BufferFromShm(-1, 0);
147 } 149 }
148 return BufferFromShm(shm_handle, shm_size); 150 return BufferFromShm(shm_handle, shm_size);
149 } 151 }
150 152
151 void CommandBufferNacl::SetToken(int32 token) { 153 void CommandBufferNacl::SetToken(int32 token) {
152 DebugPrintf("CommandBufferNacl::SetToken\n"); 154 DebugPrintf("CommandBufferNacl::SetToken\n");
153 // Not implemented by proxy. 155 // Not implemented by proxy.
154 GPU_NOTREACHED(); 156 GPU_NOTREACHED();
(...skipping 30 matching lines...) Expand all
185 187
186 // static 188 // static
187 gpu::CommandBuffer::State CommandBufferNacl::ErrorGpuState() { 189 gpu::CommandBuffer::State CommandBufferNacl::ErrorGpuState() {
188 gpu::CommandBuffer::State state; 190 gpu::CommandBuffer::State state;
189 state.error = gpu::error::kGenericError; 191 state.error = gpu::error::kGenericError;
190 return state; 192 return state;
191 } 193 }
192 194
193 // static 195 // static
194 gpu::CommandBuffer::State CommandBufferNacl::PpapiToGpuState( 196 gpu::CommandBuffer::State CommandBufferNacl::PpapiToGpuState(
195 PP_Context3DTrustedState s) { 197 PP_Graphics3DTrustedState s) {
196 gpu::CommandBuffer::State state; 198 gpu::CommandBuffer::State state;
197 state.num_entries = s.num_entries; 199 state.num_entries = s.num_entries;
198 state.get_offset = s.get_offset; 200 state.get_offset = s.get_offset;
199 state.put_offset = s.put_offset; 201 state.put_offset = s.put_offset;
200 state.token = s.token; 202 state.token = s.token;
201 state.error = static_cast<gpu::error::Error>(s.error); 203 state.error = static_cast<gpu::error::Error>(s.error);
202 return state; 204 return state;
203 } 205 }
OLDNEW
« no previous file with comments | « src/shared/ppapi_proxy/command_buffer_nacl.h ('k') | src/shared/ppapi_proxy/nacl.scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698