| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 gapi_->EndFrame(); | 145 gapi_->EndFrame(); |
| 146 return BufferSyncInterface::kParseNoError; | 146 return BufferSyncInterface::kParseNoError; |
| 147 } | 147 } |
| 148 | 148 |
| 149 BufferSyncInterface::ParseError GAPIDecoder::HandleClear( | 149 BufferSyncInterface::ParseError GAPIDecoder::HandleClear( |
| 150 uint32 arg_count, | 150 uint32 arg_count, |
| 151 const cmd::Clear& args) { | 151 const cmd::Clear& args) { |
| 152 // Pull out some values so they can't be changed by another thread after we've | 152 // Pull out some values so they can't be changed by another thread after we've |
| 153 // validated them. | 153 // validated them. |
| 154 uint32 buffers = args.buffers; | 154 uint32 buffers = args.buffers; |
| 155 if (buffers & ~GAPIInterface::ALL_BUFFERS) | 155 if (buffers & ~command_buffer::kAllBuffers) |
| 156 return BufferSyncInterface::kParseInvalidArguments; | 156 return BufferSyncInterface::kParseInvalidArguments; |
| 157 RGBA rgba; | 157 RGBA rgba; |
| 158 rgba.red = args.red; | 158 rgba.red = args.red; |
| 159 rgba.green = args.green; | 159 rgba.green = args.green; |
| 160 rgba.blue = args.blue; | 160 rgba.blue = args.blue; |
| 161 rgba.alpha = args.alpha; | 161 rgba.alpha = args.alpha; |
| 162 gapi_->Clear(buffers, rgba, args.depth, args.stencil); | 162 gapi_->Clear(buffers, rgba, args.depth, args.stencil); |
| 163 return BufferSyncInterface::kParseNoError; | 163 return BufferSyncInterface::kParseNoError; |
| 164 } | 164 } |
| 165 | 165 |
| 166 BufferSyncInterface::ParseError GAPIDecoder::HandleSetViewport( | 166 BufferSyncInterface::ParseError GAPIDecoder::HandleSetViewport( |
| 167 uint32 arg_count, | 167 uint32 arg_count, |
| 168 const cmd::SetViewport& args) { | 168 const cmd::SetViewport& args) { |
| 169 gapi_->SetViewport(args.left, | 169 gapi_->SetViewport(args.left, |
| 170 args.top, | 170 args.top, |
| 171 args.width, | 171 args.width, |
| 172 args.height, | 172 args.height, |
| 173 args.z_min, | 173 args.z_min, |
| 174 args.z_max); | 174 args.z_max); |
| 175 return BufferSyncInterface::kParseNoError; | 175 return BufferSyncInterface::kParseNoError; |
| 176 } | 176 } |
| 177 | 177 |
| 178 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateVertexBuffer( | 178 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateVertexBuffer( |
| 179 uint32 arg_count, | 179 uint32 arg_count, |
| 180 const cmd::CreateVertexBuffer& args) { | 180 const cmd::CreateVertexBuffer& args) { |
| 181 return gapi_->CreateVertexBuffer(args.id, args.size, args.flags); | 181 return gapi_->CreateVertexBuffer( |
| 182 args.vertex_buffer_id, args.size, args.flags); |
| 182 } | 183 } |
| 183 | 184 |
| 184 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyVertexBuffer( | 185 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyVertexBuffer( |
| 185 uint32 arg_count, | 186 uint32 arg_count, |
| 186 const cmd::DestroyVertexBuffer& args) { | 187 const cmd::DestroyVertexBuffer& args) { |
| 187 return gapi_->DestroyVertexBuffer(args.id); | 188 return gapi_->DestroyVertexBuffer(args.vertex_buffer_id); |
| 188 } | 189 } |
| 189 | 190 |
| 190 BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexBufferDataImmediate( | 191 BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexBufferDataImmediate( |
| 191 uint32 arg_count, | 192 uint32 arg_count, |
| 192 const cmd::SetVertexBufferDataImmediate& args) { | 193 const cmd::SetVertexBufferDataImmediate& args) { |
| 193 return gapi_->SetVertexBufferData(args.id, args.offset, | 194 return gapi_->SetVertexBufferData(args.vertex_buffer_id, args.offset, |
| 194 ImmediateDataSize(arg_count, args), | 195 ImmediateDataSize(arg_count, args), |
| 195 AddressAfterStruct(args)); | 196 AddressAfterStruct(args)); |
| 196 } | 197 } |
| 197 | 198 |
| 198 BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexBufferData( | 199 BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexBufferData( |
| 199 uint32 arg_count, | 200 uint32 arg_count, |
| 200 const cmd::SetVertexBufferData& args) { | 201 const cmd::SetVertexBufferData& args) { |
| 201 // Pull out some values so they can't be changed by another thread after we've | 202 // Pull out some values so they can't be changed by another thread after we've |
| 202 // validated them. | 203 // validated them. |
| 203 uint32 size = args.size; | 204 uint32 size = args.size; |
| 204 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 205 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
| 205 args.shared_memory.offset, | 206 args.shared_memory.offset, |
| 206 size); | 207 size); |
| 207 if (!data) return BufferSyncInterface::kParseInvalidArguments; | 208 if (!data) return BufferSyncInterface::kParseInvalidArguments; |
| 208 return gapi_->SetVertexBufferData(args.id, args.offset, size, data); | 209 return gapi_->SetVertexBufferData( |
| 210 args.vertex_buffer_id, args.offset, size, data); |
| 209 } | 211 } |
| 210 | 212 |
| 211 BufferSyncInterface::ParseError GAPIDecoder::HandleGetVertexBufferData( | 213 BufferSyncInterface::ParseError GAPIDecoder::HandleGetVertexBufferData( |
| 212 uint32 arg_count, | 214 uint32 arg_count, |
| 213 const cmd::GetVertexBufferData& args) { | 215 const cmd::GetVertexBufferData& args) { |
| 214 // Pull out some values so they can't be changed by another thread after we've | 216 // Pull out some values so they can't be changed by another thread after we've |
| 215 // validated them. | 217 // validated them. |
| 216 uint32 size = args.size; | 218 uint32 size = args.size; |
| 217 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 219 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
| 218 args.shared_memory.offset, | 220 args.shared_memory.offset, |
| 219 size); | 221 size); |
| 220 if (!data) return BufferSyncInterface::kParseInvalidArguments; | 222 if (!data) return BufferSyncInterface::kParseInvalidArguments; |
| 221 return gapi_->GetVertexBufferData(args.id, args.offset, size, data); | 223 return gapi_->GetVertexBufferData( |
| 224 args.vertex_buffer_id, args.offset, size, data); |
| 222 } | 225 } |
| 223 | 226 |
| 224 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateIndexBuffer( | 227 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateIndexBuffer( |
| 225 uint32 arg_count, | 228 uint32 arg_count, |
| 226 const cmd::CreateIndexBuffer& args) { | 229 const cmd::CreateIndexBuffer& args) { |
| 227 return gapi_->CreateIndexBuffer(args.id, args.size, args.flags); | 230 return gapi_->CreateIndexBuffer(args.index_buffer_id, args.size, args.flags); |
| 228 } | 231 } |
| 229 | 232 |
| 230 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyIndexBuffer( | 233 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyIndexBuffer( |
| 231 uint32 arg_count, | 234 uint32 arg_count, |
| 232 const cmd::DestroyIndexBuffer& args) { | 235 const cmd::DestroyIndexBuffer& args) { |
| 233 return gapi_->DestroyIndexBuffer(args.id); | 236 return gapi_->DestroyIndexBuffer(args.index_buffer_id); |
| 234 } | 237 } |
| 235 | 238 |
| 236 BufferSyncInterface::ParseError GAPIDecoder::HandleSetIndexBufferDataImmediate( | 239 BufferSyncInterface::ParseError GAPIDecoder::HandleSetIndexBufferDataImmediate( |
| 237 uint32 arg_count, | 240 uint32 arg_count, |
| 238 const cmd::SetIndexBufferDataImmediate& args) { | 241 const cmd::SetIndexBufferDataImmediate& args) { |
| 239 return gapi_->SetIndexBufferData(args.id, args.offset, | 242 return gapi_->SetIndexBufferData(args.index_buffer_id, args.offset, |
| 240 ImmediateDataSize(arg_count, args), | 243 ImmediateDataSize(arg_count, args), |
| 241 AddressAfterStruct(args)); | 244 AddressAfterStruct(args)); |
| 242 } | 245 } |
| 243 | 246 |
| 244 BufferSyncInterface::ParseError GAPIDecoder::HandleSetIndexBufferData( | 247 BufferSyncInterface::ParseError GAPIDecoder::HandleSetIndexBufferData( |
| 245 uint32 arg_count, | 248 uint32 arg_count, |
| 246 const cmd::SetIndexBufferData& args) { | 249 const cmd::SetIndexBufferData& args) { |
| 247 // Pull out some values so they can't be changed by another thread after we've | 250 // Pull out some values so they can't be changed by another thread after we've |
| 248 // validated them. | 251 // validated them. |
| 249 uint32 size = args.size; | 252 uint32 size = args.size; |
| 250 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 253 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
| 251 args.shared_memory.offset, | 254 args.shared_memory.offset, |
| 252 size); | 255 size); |
| 253 if (!data) return BufferSyncInterface::kParseInvalidArguments; | 256 if (!data) return BufferSyncInterface::kParseInvalidArguments; |
| 254 return gapi_->SetIndexBufferData(args.id, args.offset, size, data); | 257 return gapi_->SetIndexBufferData( |
| 258 args.index_buffer_id, args.offset, size, data); |
| 255 } | 259 } |
| 256 | 260 |
| 257 BufferSyncInterface::ParseError GAPIDecoder::HandleGetIndexBufferData( | 261 BufferSyncInterface::ParseError GAPIDecoder::HandleGetIndexBufferData( |
| 258 uint32 arg_count, | 262 uint32 arg_count, |
| 259 const cmd::GetIndexBufferData& args) { | 263 const cmd::GetIndexBufferData& args) { |
| 260 // Pull out some values so they can't be changed by another thread after we've | 264 // Pull out some values so they can't be changed by another thread after we've |
| 261 // validated them. | 265 // validated them. |
| 262 uint32 size = args.size; | 266 uint32 size = args.size; |
| 263 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 267 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
| 264 args.shared_memory.offset, | 268 args.shared_memory.offset, |
| 265 size); | 269 size); |
| 266 if (!data) return BufferSyncInterface::kParseInvalidArguments; | 270 if (!data) return BufferSyncInterface::kParseInvalidArguments; |
| 267 return gapi_->GetIndexBufferData(args.id, args.offset, size, data); | 271 return gapi_->GetIndexBufferData( |
| 272 args.index_buffer_id, args.offset, size, data); |
| 268 } | 273 } |
| 269 | 274 |
| 270 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateVertexStruct( | 275 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateVertexStruct( |
| 271 uint32 arg_count, | 276 uint32 arg_count, |
| 272 const cmd::CreateVertexStruct& args) { | 277 const cmd::CreateVertexStruct& args) { |
| 273 return gapi_->CreateVertexStruct(args.id, args.input_count); | 278 return gapi_->CreateVertexStruct(args.vertex_struct_id, args.input_count); |
| 274 } | 279 } |
| 275 | 280 |
| 276 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyVertexStruct( | 281 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyVertexStruct( |
| 277 uint32 arg_count, | 282 uint32 arg_count, |
| 278 const cmd::DestroyVertexStruct& args) { | 283 const cmd::DestroyVertexStruct& args) { |
| 279 return gapi_->DestroyVertexStruct(args.id); | 284 return gapi_->DestroyVertexStruct(args.vertex_struct_id); |
| 280 } | 285 } |
| 281 | 286 |
| 282 BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexInput( | 287 BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexInput( |
| 283 uint32 arg_count, | 288 uint32 arg_count, |
| 284 const cmd::SetVertexInput& args) { | 289 const cmd::SetVertexInput& args) { |
| 285 namespace cmd = set_vertex_input_cmd; | 290 unsigned int type_stride_semantic = args.type_stride_semantic; |
| 286 unsigned int type_stride_semantic = args.fixme4; | 291 unsigned int semantic_index = |
| 287 unsigned int semantic_index = cmd::SemanticIndex::Get(type_stride_semantic); | 292 cmd::SetVertexInput::SemanticIndex::Get(type_stride_semantic); |
| 288 unsigned int semantic = cmd::Semantic::Get(type_stride_semantic); | 293 unsigned int semantic = |
| 289 unsigned int type = cmd::Type::Get(type_stride_semantic); | 294 cmd::SetVertexInput::Semantic::Get(type_stride_semantic); |
| 290 unsigned int stride = cmd::Stride::Get(type_stride_semantic); | 295 unsigned int type = |
| 291 if (semantic >= vertex_struct::NUM_SEMANTICS || | 296 cmd::SetVertexInput::Type::Get(type_stride_semantic); |
| 292 type >= vertex_struct::NUM_TYPES || stride == 0) | 297 unsigned int stride = |
| 298 cmd::SetVertexInput::Stride::Get(type_stride_semantic); |
| 299 if (semantic >= vertex_struct::kNumSemantics || |
| 300 type >= vertex_struct::kNumTypes || stride == 0) |
| 293 return BufferSyncInterface::kParseInvalidArguments; | 301 return BufferSyncInterface::kParseInvalidArguments; |
| 294 return gapi_->SetVertexInput( | 302 return gapi_->SetVertexInput( |
| 295 args.vertex_struct_id, args.input_index, args.vertex_buffer_id, | 303 args.vertex_struct_id, args.input_index, args.vertex_buffer_id, |
| 296 args.offset, stride, | 304 args.offset, stride, |
| 297 static_cast<vertex_struct::Type>(type), | 305 static_cast<vertex_struct::Type>(type), |
| 298 static_cast<vertex_struct::Semantic>(semantic), | 306 static_cast<vertex_struct::Semantic>(semantic), |
| 299 semantic_index); | 307 semantic_index); |
| 300 } | 308 } |
| 301 | 309 |
| 302 BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexStruct( | 310 BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexStruct( |
| 303 uint32 arg_count, | 311 uint32 arg_count, |
| 304 const cmd::SetVertexStruct& args) { | 312 const cmd::SetVertexStruct& args) { |
| 305 return gapi_->SetVertexStruct(args.id); | 313 return gapi_->SetVertexStruct(args.vertex_struct_id); |
| 306 } | 314 } |
| 307 | 315 |
| 308 BufferSyncInterface::ParseError GAPIDecoder::HandleDraw( | 316 BufferSyncInterface::ParseError GAPIDecoder::HandleDraw( |
| 309 uint32 arg_count, | 317 uint32 arg_count, |
| 310 const cmd::Draw& args) { | 318 const cmd::Draw& args) { |
| 311 // Pull out some values so they can't be changed by another thread after we've | 319 // Pull out some values so they can't be changed by another thread after we've |
| 312 // validated them. | 320 // validated them. |
| 313 uint32 primitive_type = args.primitive_type; | 321 uint32 primitive_type = args.primitive_type; |
| 314 if (primitive_type >= GAPIInterface::MAX_PRIMITIVE_TYPE) | 322 if (primitive_type >= command_buffer::kMaxPrimitiveType) |
| 315 return BufferSyncInterface::kParseInvalidArguments; | 323 return BufferSyncInterface::kParseInvalidArguments; |
| 316 return gapi_->Draw( | 324 return gapi_->Draw( |
| 317 static_cast<GAPIInterface::PrimitiveType>(primitive_type), | 325 static_cast<command_buffer::PrimitiveType>(primitive_type), |
| 318 args.first, args.count); | 326 args.first, args.count); |
| 319 } | 327 } |
| 320 | 328 |
| 321 BufferSyncInterface::ParseError GAPIDecoder::HandleDrawIndexed( | 329 BufferSyncInterface::ParseError GAPIDecoder::HandleDrawIndexed( |
| 322 uint32 arg_count, | 330 uint32 arg_count, |
| 323 const cmd::DrawIndexed& args) { | 331 const cmd::DrawIndexed& args) { |
| 324 // Pull out some values so they can't be changed by another thread after we've | 332 // Pull out some values so they can't be changed by another thread after we've |
| 325 // validated them. | 333 // validated them. |
| 326 uint32 primitive_type = args.primitive_type; | 334 uint32 primitive_type = args.primitive_type; |
| 327 if (primitive_type >= GAPIInterface::MAX_PRIMITIVE_TYPE) | 335 if (primitive_type >= command_buffer::kMaxPrimitiveType) |
| 328 return BufferSyncInterface::kParseInvalidArguments; | 336 return BufferSyncInterface::kParseInvalidArguments; |
| 329 return gapi_->DrawIndexed( | 337 return gapi_->DrawIndexed( |
| 330 static_cast<GAPIInterface::PrimitiveType>(primitive_type), | 338 static_cast<command_buffer::PrimitiveType>(primitive_type), |
| 331 args.index_buffer_id, | 339 args.index_buffer_id, |
| 332 args.first, args.count, args.min_index, args.max_index); | 340 args.first, args.count, args.min_index, args.max_index); |
| 333 } | 341 } |
| 334 | 342 |
| 335 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateEffect( | 343 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateEffect( |
| 336 uint32 arg_count, | 344 uint32 arg_count, |
| 337 const cmd::CreateEffect& args) { | 345 const cmd::CreateEffect& args) { |
| 338 // Pull out some values so they can't be changed by another thread after we've | 346 // Pull out some values so they can't be changed by another thread after we've |
| 339 // validated them. | 347 // validated them. |
| 340 uint32 size = args.size; | 348 uint32 size = args.size; |
| 341 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 349 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
| 342 args.shared_memory.offset, | 350 args.shared_memory.offset, |
| 343 size); | 351 size); |
| 344 if (!data) return BufferSyncInterface::kParseInvalidArguments; | 352 if (!data) return BufferSyncInterface::kParseInvalidArguments; |
| 345 return gapi_->CreateEffect(args.id, size, data); | 353 return gapi_->CreateEffect(args.effect_id, size, data); |
| 346 } | 354 } |
| 347 | 355 |
| 348 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateEffectImmediate( | 356 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateEffectImmediate( |
| 349 uint32 arg_count, | 357 uint32 arg_count, |
| 350 const cmd::CreateEffectImmediate& args) { | 358 const cmd::CreateEffectImmediate& args) { |
| 351 // Pull out some values so they can't be changed by another thread after we've | 359 // Pull out some values so they can't be changed by another thread after we've |
| 352 // validated them. | 360 // validated them. |
| 353 uint32 size = args.size; | 361 uint32 size = args.size; |
| 354 uint32 data_size = ImmediateDataSize(arg_count, args); | 362 uint32 data_size = ImmediateDataSize(arg_count, args); |
| 355 if (size > data_size) | 363 if (size > data_size) |
| 356 return BufferSyncInterface::kParseInvalidArguments; | 364 return BufferSyncInterface::kParseInvalidArguments; |
| 357 return gapi_->CreateEffect(args.id, size, AddressAfterStruct(args)); | 365 return gapi_->CreateEffect(args.effect_id, size, AddressAfterStruct(args)); |
| 358 } | 366 } |
| 359 | 367 |
| 360 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyEffect( | 368 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyEffect( |
| 361 uint32 arg_count, | 369 uint32 arg_count, |
| 362 const cmd::DestroyEffect& args) { | 370 const cmd::DestroyEffect& args) { |
| 363 return gapi_->DestroyEffect(args.id); | 371 return gapi_->DestroyEffect(args.effect_id); |
| 364 } | 372 } |
| 365 | 373 |
| 366 BufferSyncInterface::ParseError GAPIDecoder::HandleSetEffect( | 374 BufferSyncInterface::ParseError GAPIDecoder::HandleSetEffect( |
| 367 uint32 arg_count, | 375 uint32 arg_count, |
| 368 const cmd::SetEffect& args) { | 376 const cmd::SetEffect& args) { |
| 369 return gapi_->SetEffect(args.id); | 377 return gapi_->SetEffect(args.effect_id); |
| 370 } | 378 } |
| 371 | 379 |
| 372 BufferSyncInterface::ParseError GAPIDecoder::HandleGetParamCount( | 380 BufferSyncInterface::ParseError GAPIDecoder::HandleGetParamCount( |
| 373 uint32 arg_count, | 381 uint32 arg_count, |
| 374 const cmd::GetParamCount& args) { | 382 const cmd::GetParamCount& args) { |
| 375 // Pull out some values so they can't be changed by another thread after we've | 383 // Pull out some values so they can't be changed by another thread after we've |
| 376 // validated them. | 384 // validated them. |
| 377 uint32 size = args.size; | 385 uint32 size = args.size; |
| 378 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 386 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
| 379 args.shared_memory.offset, | 387 args.shared_memory.offset, |
| 380 size); | 388 size); |
| 381 if (!data) return BufferSyncInterface::kParseInvalidArguments; | 389 if (!data) return BufferSyncInterface::kParseInvalidArguments; |
| 382 return gapi_->GetParamCount(args.id, size, data); | 390 return gapi_->GetParamCount(args.effect_id, size, data); |
| 383 } | 391 } |
| 384 | 392 |
| 385 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateParam( | 393 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateParam( |
| 386 uint32 arg_count, | 394 uint32 arg_count, |
| 387 const cmd::CreateParam& args) { | 395 const cmd::CreateParam& args) { |
| 388 return gapi_->CreateParam(args.param_id, args.effect_id, args.index); | 396 return gapi_->CreateParam(args.param_id, args.effect_id, args.index); |
| 389 } | 397 } |
| 390 | 398 |
| 391 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateParamByName( | 399 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateParamByName( |
| 392 uint32 arg_count, | 400 uint32 arg_count, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 411 uint32 data_size = ImmediateDataSize(arg_count, args); | 419 uint32 data_size = ImmediateDataSize(arg_count, args); |
| 412 if (size > data_size) | 420 if (size > data_size) |
| 413 return BufferSyncInterface::kParseInvalidArguments; | 421 return BufferSyncInterface::kParseInvalidArguments; |
| 414 return gapi_->CreateParamByName(args.param_id, args.effect_id, size, | 422 return gapi_->CreateParamByName(args.param_id, args.effect_id, size, |
| 415 AddressAfterStruct(args)); | 423 AddressAfterStruct(args)); |
| 416 } | 424 } |
| 417 | 425 |
| 418 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyParam( | 426 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyParam( |
| 419 uint32 arg_count, | 427 uint32 arg_count, |
| 420 const cmd::DestroyParam& args) { | 428 const cmd::DestroyParam& args) { |
| 421 return gapi_->DestroyParam(args.id); | 429 return gapi_->DestroyParam(args.param_id); |
| 422 } | 430 } |
| 423 | 431 |
| 424 BufferSyncInterface::ParseError GAPIDecoder::HandleSetParamData( | 432 BufferSyncInterface::ParseError GAPIDecoder::HandleSetParamData( |
| 425 uint32 arg_count, | 433 uint32 arg_count, |
| 426 const cmd::SetParamData& args) { | 434 const cmd::SetParamData& args) { |
| 427 // Pull out some values so they can't be changed by another thread after we've | 435 // Pull out some values so they can't be changed by another thread after we've |
| 428 // validated them. | 436 // validated them. |
| 429 uint32 size = args.size; | 437 uint32 size = args.size; |
| 430 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 438 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
| 431 args.shared_memory.offset, | 439 args.shared_memory.offset, |
| 432 size); | 440 size); |
| 433 if (!data) return BufferSyncInterface::kParseInvalidArguments; | 441 if (!data) return BufferSyncInterface::kParseInvalidArguments; |
| 434 return gapi_->SetParamData(args.id, size, data); | 442 return gapi_->SetParamData(args.param_id, size, data); |
| 435 } | 443 } |
| 436 | 444 |
| 437 BufferSyncInterface::ParseError GAPIDecoder::HandleSetParamDataImmediate( | 445 BufferSyncInterface::ParseError GAPIDecoder::HandleSetParamDataImmediate( |
| 438 uint32 arg_count, | 446 uint32 arg_count, |
| 439 const cmd::SetParamDataImmediate& args) { | 447 const cmd::SetParamDataImmediate& args) { |
| 440 // Pull out some values so they can't be changed by another thread after we've | 448 // Pull out some values so they can't be changed by another thread after we've |
| 441 // validated them. | 449 // validated them. |
| 442 uint32 size = args.size; | 450 uint32 size = args.size; |
| 443 uint32 data_size = ImmediateDataSize(arg_count, args); | 451 uint32 data_size = ImmediateDataSize(arg_count, args); |
| 444 if (size > data_size) | 452 if (size > data_size) |
| 445 return BufferSyncInterface::kParseInvalidArguments; | 453 return BufferSyncInterface::kParseInvalidArguments; |
| 446 return gapi_->SetParamData(args.id, size, AddressAfterStruct(args)); | 454 return gapi_->SetParamData(args.param_id, size, AddressAfterStruct(args)); |
| 447 } | 455 } |
| 448 | 456 |
| 449 BufferSyncInterface::ParseError GAPIDecoder::HandleGetParamDesc( | 457 BufferSyncInterface::ParseError GAPIDecoder::HandleGetParamDesc( |
| 450 uint32 arg_count, | 458 uint32 arg_count, |
| 451 const cmd::GetParamDesc& args) { | 459 const cmd::GetParamDesc& args) { |
| 452 // Pull out some values so they can't be changed by another thread after we've | 460 // Pull out some values so they can't be changed by another thread after we've |
| 453 // validated them. | 461 // validated them. |
| 454 uint32 size = args.size; | 462 uint32 size = args.size; |
| 455 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 463 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
| 456 args.shared_memory.offset, | 464 args.shared_memory.offset, |
| 457 size); | 465 size); |
| 458 if (!data) return BufferSyncInterface::kParseInvalidArguments; | 466 if (!data) return BufferSyncInterface::kParseInvalidArguments; |
| 459 return gapi_->GetParamDesc(args.id, size, data); | 467 return gapi_->GetParamDesc(args.param_id, size, data); |
| 460 } | 468 } |
| 461 | 469 |
| 462 BufferSyncInterface::ParseError GAPIDecoder::HandleGetStreamCount( | 470 BufferSyncInterface::ParseError GAPIDecoder::HandleGetStreamCount( |
| 463 uint32 arg_count, | 471 uint32 arg_count, |
| 464 const cmd::GetStreamCount& args) { | 472 const cmd::GetStreamCount& args) { |
| 465 // Pull out some values so they can't be changed by another thread after we've | 473 // Pull out some values so they can't be changed by another thread after we've |
| 466 // validated them. | 474 // validated them. |
| 467 uint32 size = args.size; | 475 uint32 size = args.size; |
| 468 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 476 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
| 469 args.shared_memory.offset, | 477 args.shared_memory.offset, |
| 470 size); | 478 size); |
| 471 if (!data) return BufferSyncInterface::kParseInvalidArguments; | 479 if (!data) return BufferSyncInterface::kParseInvalidArguments; |
| 472 return gapi_->GetStreamCount(args.id, size, data); | 480 return gapi_->GetStreamCount(args.effect_id, size, data); |
| 473 } | 481 } |
| 474 | 482 |
| 475 BufferSyncInterface::ParseError GAPIDecoder::HandleGetStreamDesc( | 483 BufferSyncInterface::ParseError GAPIDecoder::HandleGetStreamDesc( |
| 476 uint32 arg_count, | 484 uint32 arg_count, |
| 477 const cmd::GetStreamDesc& args) { | 485 const cmd::GetStreamDesc& args) { |
| 478 // Pull out some values so they can't be changed by another thread after we've | 486 // Pull out some values so they can't be changed by another thread after we've |
| 479 // validated them. | 487 // validated them. |
| 480 uint32 size = args.size; | 488 uint32 size = args.size; |
| 481 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 489 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
| 482 args.shared_memory.offset, | 490 args.shared_memory.offset, |
| 483 size); | 491 size); |
| 484 if (!data) return BufferSyncInterface::kParseInvalidArguments; | 492 if (!data) return BufferSyncInterface::kParseInvalidArguments; |
| 485 return gapi_->GetStreamDesc(args.id, args.index, size, data); | 493 return gapi_->GetStreamDesc(args.effect_id, args.index, size, data); |
| 486 } | 494 } |
| 487 | 495 |
| 488 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyTexture( | 496 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyTexture( |
| 489 uint32 arg_count, | 497 uint32 arg_count, |
| 490 const cmd::DestroyTexture& args) { | 498 const cmd::DestroyTexture& args) { |
| 491 return gapi_->DestroyTexture(args.id); | 499 return gapi_->DestroyTexture(args.texture_id); |
| 492 } | 500 } |
| 493 | 501 |
| 494 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateTexture2d( | 502 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateTexture2d( |
| 495 uint32 arg_count, | 503 uint32 arg_count, |
| 496 const cmd::CreateTexture2d& args) { | 504 const cmd::CreateTexture2d& args) { |
| 497 namespace cmd = create_texture_2d_cmd; | 505 unsigned int width_height = args.width_height; |
| 498 unsigned int width_height = args.fixme1; | 506 unsigned int levels_format_flags = args.levels_format_flags; |
| 499 unsigned int levels_format_flags = args.fixme2; | 507 unsigned int width = cmd::CreateTexture2d::Width::Get(width_height); |
| 500 unsigned int width = cmd::Width::Get(width_height); | 508 unsigned int height = cmd::CreateTexture2d::Height::Get(width_height); |
| 501 unsigned int height = cmd::Height::Get(width_height); | 509 unsigned int levels = cmd::CreateTexture2d::Levels::Get(levels_format_flags); |
| 502 unsigned int levels = cmd::Levels::Get(levels_format_flags); | 510 unsigned int unused = cmd::CreateTexture2d::Unused::Get(levels_format_flags); |
| 503 unsigned int unused = cmd::Unused::Get(levels_format_flags); | 511 unsigned int format = cmd::CreateTexture2d::Format::Get(levels_format_flags); |
| 504 unsigned int format = cmd::Format::Get(levels_format_flags); | 512 unsigned int flags = cmd::CreateTexture2d::Flags::Get(levels_format_flags); |
| 505 unsigned int flags = cmd::Flags::Get(levels_format_flags); | |
| 506 unsigned int max_levels = | 513 unsigned int max_levels = |
| 507 1 + base::bits::Log2Ceiling(std::max(width, height)); | 514 1 + base::bits::Log2Ceiling(std::max(width, height)); |
| 508 if ((width == 0) || (height == 0) || (levels > max_levels) || | 515 if ((width == 0) || (height == 0) || (levels > max_levels) || |
| 509 (unused != 0) || (format >= texture::NUM_FORMATS) || (levels == 0)) | 516 (unused != 0) || (format >= texture::kNumFormats) || (levels == 0)) |
| 510 return BufferSyncInterface::kParseInvalidArguments; | 517 return BufferSyncInterface::kParseInvalidArguments; |
| 511 bool enable_render_surfaces = !!flags; | 518 bool enable_render_surfaces = !!flags; |
| 512 return gapi_->CreateTexture2D(args.texture_id, width, height, levels, | 519 return gapi_->CreateTexture2D(args.texture_id, width, height, levels, |
| 513 static_cast<texture::Format>(format), flags, | 520 static_cast<texture::Format>(format), flags, |
| 514 enable_render_surfaces); | 521 enable_render_surfaces); |
| 515 } | 522 } |
| 516 | 523 |
| 517 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateTexture3d( | 524 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateTexture3d( |
| 518 uint32 arg_count, | 525 uint32 arg_count, |
| 519 const cmd::CreateTexture3d& args) { | 526 const cmd::CreateTexture3d& args) { |
| 520 namespace cmd = create_texture_3d_cmd; | 527 unsigned int width_height = args.width_height; |
| 521 unsigned int width_height = args.fixme1; | 528 unsigned int depth_unused = args.depth_unused; |
| 522 unsigned int depth_unused = args.fixme2; | 529 unsigned int levels_format_flags = args.levels_format_flags; |
| 523 unsigned int levels_format_flags = args.fixme3; | 530 unsigned int width = cmd::CreateTexture3d::Width::Get(width_height); |
| 524 unsigned int width = cmd::Width::Get(width_height); | 531 unsigned int height = cmd::CreateTexture3d::Height::Get(width_height); |
| 525 unsigned int height = cmd::Height::Get(width_height); | 532 unsigned int depth = cmd::CreateTexture3d::Depth::Get(depth_unused); |
| 526 unsigned int depth = cmd::Depth::Get(depth_unused); | 533 unsigned int unused1 = cmd::CreateTexture3d::Unused1::Get(depth_unused); |
| 527 unsigned int unused1 = cmd::Unused1::Get(depth_unused); | 534 unsigned int levels = cmd::CreateTexture3d::Levels::Get(levels_format_flags); |
| 528 unsigned int levels = cmd::Levels::Get(levels_format_flags); | 535 unsigned int unused2 = |
| 529 unsigned int unused2 = cmd::Unused2::Get(levels_format_flags); | 536 cmd::CreateTexture3d::Unused2::Get(levels_format_flags); |
| 530 unsigned int format = cmd::Format::Get(levels_format_flags); | 537 unsigned int format = cmd::CreateTexture3d::Format::Get(levels_format_flags); |
| 531 unsigned int flags = cmd::Flags::Get(levels_format_flags); | 538 unsigned int flags = cmd::CreateTexture3d::Flags::Get(levels_format_flags); |
| 532 unsigned int max_levels = | 539 unsigned int max_levels = |
| 533 1 + base::bits::Log2Ceiling(std::max(depth, std::max(width, height))); | 540 1 + base::bits::Log2Ceiling(std::max(depth, std::max(width, height))); |
| 534 if ((width == 0) || (height == 0) || (depth == 0) || | 541 if ((width == 0) || (height == 0) || (depth == 0) || |
| 535 (levels > max_levels) || (unused1 != 0) || (unused2 != 0) || | 542 (levels > max_levels) || (unused1 != 0) || (unused2 != 0) || |
| 536 (format >= texture::NUM_FORMATS) || (levels == 0)) | 543 (format >= texture::kNumFormats) || (levels == 0)) |
| 537 return BufferSyncInterface::kParseInvalidArguments; | 544 return BufferSyncInterface::kParseInvalidArguments; |
| 538 bool enable_render_surfaces = !!flags; | 545 bool enable_render_surfaces = !!flags; |
| 539 return gapi_->CreateTexture3D(args.texture_id, width, height, depth, levels, | 546 return gapi_->CreateTexture3D(args.texture_id, width, height, depth, levels, |
| 540 static_cast<texture::Format>(format), flags, | 547 static_cast<texture::Format>(format), flags, |
| 541 enable_render_surfaces); | 548 enable_render_surfaces); |
| 542 } | 549 } |
| 543 | 550 |
| 544 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateTextureCube( | 551 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateTextureCube( |
| 545 uint32 arg_count, | 552 uint32 arg_count, |
| 546 const cmd::CreateTextureCube& args) { | 553 const cmd::CreateTextureCube& args) { |
| 547 namespace cmd = create_texture_cube_cmd; | |
| 548 unsigned int side_unused = args.edge_length; | 554 unsigned int side_unused = args.edge_length; |
| 549 unsigned int levels_format_flags = args.fixme2; | 555 unsigned int levels_format_flags = args.levels_format_flags; |
| 550 unsigned int side = cmd::Side::Get(side_unused); | 556 unsigned int side = cmd::CreateTextureCube::Side::Get(side_unused); |
| 551 unsigned int unused1 = cmd::Unused1::Get(side_unused); | 557 unsigned int unused1 = cmd::CreateTextureCube::Unused1::Get(side_unused); |
| 552 unsigned int levels = cmd::Levels::Get(levels_format_flags); | 558 unsigned int levels = |
| 553 unsigned int unused2 = cmd::Unused2::Get(levels_format_flags); | 559 cmd::CreateTextureCube::Levels::Get(levels_format_flags); |
| 554 unsigned int format = cmd::Format::Get(levels_format_flags); | 560 unsigned int unused2 = |
| 555 unsigned int flags = cmd::Flags::Get(levels_format_flags); | 561 cmd::CreateTextureCube::Unused2::Get(levels_format_flags); |
| 562 unsigned int format = |
| 563 cmd::CreateTextureCube::Format::Get(levels_format_flags); |
| 564 unsigned int flags = cmd::CreateTextureCube::Flags::Get(levels_format_flags); |
| 556 unsigned int max_levels = 1 + base::bits::Log2Ceiling(side); | 565 unsigned int max_levels = 1 + base::bits::Log2Ceiling(side); |
| 557 if ((side == 0) || (levels > max_levels) || (unused1 != 0) || | 566 if ((side == 0) || (levels > max_levels) || (unused1 != 0) || |
| 558 (unused2 != 0) || (format >= texture::NUM_FORMATS) || (levels == 0)) | 567 (unused2 != 0) || (format >= texture::kNumFormats) || (levels == 0)) |
| 559 return BufferSyncInterface::kParseInvalidArguments; | 568 return BufferSyncInterface::kParseInvalidArguments; |
| 560 bool enable_render_surfaces = !!flags; | 569 bool enable_render_surfaces = !!flags; |
| 561 return gapi_->CreateTextureCube(args.texture_id, side, levels, | 570 return gapi_->CreateTextureCube(args.texture_id, side, levels, |
| 562 static_cast<texture::Format>(format), | 571 static_cast<texture::Format>(format), |
| 563 flags, enable_render_surfaces); | 572 flags, enable_render_surfaces); |
| 564 } | 573 } |
| 565 | 574 |
| 566 BufferSyncInterface::ParseError GAPIDecoder::HandleSetTextureData( | 575 BufferSyncInterface::ParseError GAPIDecoder::HandleSetTextureData( |
| 567 uint32 arg_count, | 576 uint32 arg_count, |
| 568 const cmd::SetTextureData& args) { | 577 const cmd::SetTextureData& args) { |
| 569 namespace cmd = set_texture_data_cmd; | 578 unsigned int x_y = args.x_y; |
| 570 unsigned int x_y = args.fixme1; | 579 unsigned int width_height = args.width_height; |
| 571 unsigned int width_height = args.fixme2; | 580 unsigned int z_depth = args.z_depth; |
| 572 unsigned int z_depth = args.fixme3; | 581 unsigned int level_face = args.level_face; |
| 573 unsigned int level_face = args.fixme4; | |
| 574 unsigned int size = args.size; | 582 unsigned int size = args.size; |
| 575 unsigned int x = cmd::X::Get(x_y); | 583 unsigned int x = cmd::SetTextureData::X::Get(x_y); |
| 576 unsigned int y = cmd::Y::Get(x_y); | 584 unsigned int y = cmd::SetTextureData::Y::Get(x_y); |
| 577 unsigned int width = cmd::Width::Get(width_height); | 585 unsigned int width = cmd::SetTextureData::Width::Get(width_height); |
| 578 unsigned int height = cmd::Height::Get(width_height); | 586 unsigned int height = cmd::SetTextureData::Height::Get(width_height); |
| 579 unsigned int z = cmd::Z::Get(z_depth); | 587 unsigned int z = cmd::SetTextureData::Z::Get(z_depth); |
| 580 unsigned int depth = cmd::Depth::Get(z_depth); | 588 unsigned int depth = cmd::SetTextureData::Depth::Get(z_depth); |
| 581 unsigned int level = cmd::Level::Get(level_face); | 589 unsigned int level = cmd::SetTextureData::Level::Get(level_face); |
| 582 unsigned int face = cmd::Face::Get(level_face); | 590 unsigned int face = cmd::SetTextureData::Face::Get(level_face); |
| 583 unsigned int unused = cmd::Unused::Get(level_face); | 591 unsigned int unused = cmd::SetTextureData::Unused::Get(level_face); |
| 584 const void *data = GetAddressAndCheckSize(args.shared_memory.id, | 592 const void *data = GetAddressAndCheckSize(args.shared_memory.id, |
| 585 args.shared_memory.offset, size); | 593 args.shared_memory.offset, size); |
| 586 if (face >= 6 || unused != 0 || !data) | 594 if (face >= 6 || unused != 0 || !data) |
| 587 return BufferSyncInterface::kParseInvalidArguments; | 595 return BufferSyncInterface::kParseInvalidArguments; |
| 588 return gapi_->SetTextureData( | 596 return gapi_->SetTextureData( |
| 589 args.texture_id, x, y, z, width, height, depth, level, | 597 args.texture_id, x, y, z, width, height, depth, level, |
| 590 static_cast<texture::Face>(face), args.row_pitch, | 598 static_cast<texture::Face>(face), args.row_pitch, |
| 591 args.slice_pitch, size, data); | 599 args.slice_pitch, size, data); |
| 592 } | 600 } |
| 593 | 601 |
| 594 BufferSyncInterface::ParseError GAPIDecoder::HandleSetTextureDataImmediate( | 602 BufferSyncInterface::ParseError GAPIDecoder::HandleSetTextureDataImmediate( |
| 595 uint32 arg_count, | 603 uint32 arg_count, |
| 596 const cmd::SetTextureDataImmediate& args) { | 604 const cmd::SetTextureDataImmediate& args) { |
| 597 namespace cmd = set_texture_data_immediate_cmd; | 605 unsigned int x_y = args.x_y; |
| 598 unsigned int x_y = args.fixme1; | 606 unsigned int width_height = args.width_height; |
| 599 unsigned int width_height = args.fixme2; | 607 unsigned int z_depth = args.z_depth; |
| 600 unsigned int z_depth = args.fixme3; | 608 unsigned int level_face = args.level_face; |
| 601 unsigned int level_face = args.fixme4; | |
| 602 unsigned int size = args.size; | 609 unsigned int size = args.size; |
| 603 unsigned int x = cmd::X::Get(x_y); | 610 unsigned int x = cmd::SetTextureDataImmediate::X::Get(x_y); |
| 604 unsigned int y = cmd::Y::Get(x_y); | 611 unsigned int y = cmd::SetTextureDataImmediate::Y::Get(x_y); |
| 605 unsigned int width = cmd::Width::Get(width_height); | 612 unsigned int width = cmd::SetTextureDataImmediate::Width::Get(width_height); |
| 606 unsigned int height = cmd::Height::Get(width_height); | 613 unsigned int height = cmd::SetTextureDataImmediate::Height::Get(width_height); |
| 607 unsigned int z = cmd::Z::Get(z_depth); | 614 unsigned int z = cmd::SetTextureDataImmediate::Z::Get(z_depth); |
| 608 unsigned int depth = cmd::Depth::Get(z_depth); | 615 unsigned int depth = cmd::SetTextureDataImmediate::Depth::Get(z_depth); |
| 609 unsigned int level = cmd::Level::Get(level_face); | 616 unsigned int level = cmd::SetTextureDataImmediate::Level::Get(level_face); |
| 610 unsigned int face = cmd::Face::Get(level_face); | 617 unsigned int face = cmd::SetTextureDataImmediate::Face::Get(level_face); |
| 611 unsigned int unused = cmd::Unused::Get(level_face); | 618 unsigned int unused = cmd::SetTextureDataImmediate::Unused::Get(level_face); |
| 612 uint32 data_size = ImmediateDataSize(arg_count, args); | 619 uint32 data_size = ImmediateDataSize(arg_count, args); |
| 613 if (face >= 6 || unused != 0 || | 620 if (face >= 6 || unused != 0 || |
| 614 size > data_size) | 621 size > data_size) |
| 615 return BufferSyncInterface::kParseInvalidArguments; | 622 return BufferSyncInterface::kParseInvalidArguments; |
| 616 return gapi_->SetTextureData( | 623 return gapi_->SetTextureData( |
| 617 args.texture_id, x, y, z, width, height, depth, level, | 624 args.texture_id, x, y, z, width, height, depth, level, |
| 618 static_cast<texture::Face>(face), args.row_pitch, | 625 static_cast<texture::Face>(face), args.row_pitch, |
| 619 args.slice_pitch, size, AddressAfterStruct(args)); | 626 args.slice_pitch, size, AddressAfterStruct(args)); |
| 620 } | 627 } |
| 621 | 628 |
| 622 BufferSyncInterface::ParseError GAPIDecoder::HandleGetTextureData( | 629 BufferSyncInterface::ParseError GAPIDecoder::HandleGetTextureData( |
| 623 uint32 arg_count, | 630 uint32 arg_count, |
| 624 const cmd::GetTextureData& args) { | 631 const cmd::GetTextureData& args) { |
| 625 namespace cmd = get_texture_data_cmd; | 632 unsigned int x_y = args.x_y; |
| 626 unsigned int x_y = args.fixme1; | 633 unsigned int width_height = args.width_height; |
| 627 unsigned int width_height = args.fixme2; | 634 unsigned int z_depth = args.z_depth; |
| 628 unsigned int z_depth = args.fixme3; | 635 unsigned int level_face = args.level_face; |
| 629 unsigned int level_face = args.fixme4; | |
| 630 unsigned int size = args.size; | 636 unsigned int size = args.size; |
| 631 unsigned int x = cmd::X::Get(x_y); | 637 unsigned int x = cmd::GetTextureData::X::Get(x_y); |
| 632 unsigned int y = cmd::Y::Get(x_y); | 638 unsigned int y = cmd::GetTextureData::Y::Get(x_y); |
| 633 unsigned int width = cmd::Width::Get(width_height); | 639 unsigned int width = cmd::GetTextureData::Width::Get(width_height); |
| 634 unsigned int height = cmd::Height::Get(width_height); | 640 unsigned int height = cmd::GetTextureData::Height::Get(width_height); |
| 635 unsigned int z = cmd::Z::Get(z_depth); | 641 unsigned int z = cmd::GetTextureData::Z::Get(z_depth); |
| 636 unsigned int depth = cmd::Depth::Get(z_depth); | 642 unsigned int depth = cmd::GetTextureData::Depth::Get(z_depth); |
| 637 unsigned int level = cmd::Level::Get(level_face); | 643 unsigned int level = cmd::GetTextureData::Level::Get(level_face); |
| 638 unsigned int face = cmd::Face::Get(level_face); | 644 unsigned int face = cmd::GetTextureData::Face::Get(level_face); |
| 639 unsigned int unused = cmd::Unused::Get(level_face); | 645 unsigned int unused = cmd::GetTextureData::Unused::Get(level_face); |
| 640 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 646 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
| 641 args.shared_memory.offset, size); | 647 args.shared_memory.offset, size); |
| 642 if (face >= 6 || unused != 0 || !data) | 648 if (face >= 6 || unused != 0 || !data) |
| 643 return BufferSyncInterface::kParseInvalidArguments; | 649 return BufferSyncInterface::kParseInvalidArguments; |
| 644 return gapi_->GetTextureData( | 650 return gapi_->GetTextureData( |
| 645 args.texture_id, x, y, z, width, height, depth, level, | 651 args.texture_id, x, y, z, width, height, depth, level, |
| 646 static_cast<texture::Face>(face), args.row_pitch, | 652 static_cast<texture::Face>(face), args.row_pitch, |
| 647 args.slice_pitch, size, data); | 653 args.slice_pitch, size, data); |
| 648 } | 654 } |
| 649 | 655 |
| 650 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateSampler( | 656 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateSampler( |
| 651 uint32 arg_count, | 657 uint32 arg_count, |
| 652 const cmd::CreateSampler& args) { | 658 const cmd::CreateSampler& args) { |
| 653 return gapi_->CreateSampler(args.id); | 659 return gapi_->CreateSampler(args.sampler_id); |
| 654 } | 660 } |
| 655 | 661 |
| 656 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroySampler( | 662 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroySampler( |
| 657 uint32 arg_count, | 663 uint32 arg_count, |
| 658 const cmd::DestroySampler& args) { | 664 const cmd::DestroySampler& args) { |
| 659 return gapi_->DestroySampler(args.id); | 665 return gapi_->DestroySampler(args.sampler_id); |
| 660 } | 666 } |
| 661 | 667 |
| 662 BufferSyncInterface::ParseError GAPIDecoder::HandleSetSamplerStates( | 668 BufferSyncInterface::ParseError GAPIDecoder::HandleSetSamplerStates( |
| 663 uint32 arg_count, | 669 uint32 arg_count, |
| 664 const cmd::SetSamplerStates& args) { | 670 const cmd::SetSamplerStates& args) { |
| 665 namespace cmd = set_sampler_states; | 671 Uint32 arg = args.sampler_states; |
| 666 Uint32 arg = args.fixme1; | 672 if (cmd::SetSamplerStates::Unused::Get(arg) != 0) |
| 667 if (cmd::Unused::Get(arg) != 0) | |
| 668 return BufferSyncInterface::kParseInvalidArguments; | 673 return BufferSyncInterface::kParseInvalidArguments; |
| 669 unsigned int address_u_value = cmd::AddressingU::Get(arg); | 674 unsigned int address_u_value = cmd::SetSamplerStates::AddressingU::Get(arg); |
| 670 unsigned int address_v_value = cmd::AddressingV::Get(arg); | 675 unsigned int address_v_value = cmd::SetSamplerStates::AddressingV::Get(arg); |
| 671 unsigned int address_w_value = cmd::AddressingW::Get(arg); | 676 unsigned int address_w_value = cmd::SetSamplerStates::AddressingW::Get(arg); |
| 672 unsigned int mag_filter_value = cmd::MagFilter::Get(arg); | 677 unsigned int mag_filter_value = cmd::SetSamplerStates::MagFilter::Get(arg); |
| 673 unsigned int min_filter_value = cmd::MinFilter::Get(arg); | 678 unsigned int min_filter_value = cmd::SetSamplerStates::MinFilter::Get(arg); |
| 674 unsigned int mip_filter_value = cmd::MipFilter::Get(arg); | 679 unsigned int mip_filter_value = cmd::SetSamplerStates::MipFilter::Get(arg); |
| 675 unsigned int max_anisotropy = cmd::MaxAnisotropy::Get(arg); | 680 unsigned int max_anisotropy = cmd::SetSamplerStates::MaxAnisotropy::Get(arg); |
| 676 if (address_u_value >= sampler::NUM_ADDRESSING_MODE || | 681 if (address_u_value >= sampler::kNumAddressingMode || |
| 677 address_v_value >= sampler::NUM_ADDRESSING_MODE || | 682 address_v_value >= sampler::kNumAddressingMode || |
| 678 address_w_value >= sampler::NUM_ADDRESSING_MODE || | 683 address_w_value >= sampler::kNumAddressingMode || |
| 679 mag_filter_value >= sampler::NUM_FILTERING_MODE || | 684 mag_filter_value >= sampler::kNumFilteringMode || |
| 680 min_filter_value >= sampler::NUM_FILTERING_MODE || | 685 min_filter_value >= sampler::kNumFilteringMode || |
| 681 mip_filter_value >= sampler::NUM_FILTERING_MODE || | 686 mip_filter_value >= sampler::kNumFilteringMode || |
| 682 mag_filter_value == sampler::NONE || | 687 mag_filter_value == sampler::kNone || |
| 683 min_filter_value == sampler::NONE || | 688 min_filter_value == sampler::kNone || |
| 684 max_anisotropy == 0) { | 689 max_anisotropy == 0) { |
| 685 return BufferSyncInterface::kParseInvalidArguments; | 690 return BufferSyncInterface::kParseInvalidArguments; |
| 686 } | 691 } |
| 687 gapi_->SetSamplerStates( | 692 gapi_->SetSamplerStates( |
| 688 args.id, | 693 args.sampler_id, |
| 689 static_cast<sampler::AddressingMode>(address_u_value), | 694 static_cast<sampler::AddressingMode>(address_u_value), |
| 690 static_cast<sampler::AddressingMode>(address_v_value), | 695 static_cast<sampler::AddressingMode>(address_v_value), |
| 691 static_cast<sampler::AddressingMode>(address_w_value), | 696 static_cast<sampler::AddressingMode>(address_w_value), |
| 692 static_cast<sampler::FilteringMode>(mag_filter_value), | 697 static_cast<sampler::FilteringMode>(mag_filter_value), |
| 693 static_cast<sampler::FilteringMode>(min_filter_value), | 698 static_cast<sampler::FilteringMode>(min_filter_value), |
| 694 static_cast<sampler::FilteringMode>(mip_filter_value), | 699 static_cast<sampler::FilteringMode>(mip_filter_value), |
| 695 max_anisotropy); | 700 max_anisotropy); |
| 696 return BufferSyncInterface::kParseNoError; | 701 return BufferSyncInterface::kParseNoError; |
| 697 } | 702 } |
| 698 | 703 |
| 699 BufferSyncInterface::ParseError GAPIDecoder::HandleSetSamplerBorderColor( | 704 BufferSyncInterface::ParseError GAPIDecoder::HandleSetSamplerBorderColor( |
| 700 uint32 arg_count, | 705 uint32 arg_count, |
| 701 const cmd::SetSamplerBorderColor& args) { | 706 const cmd::SetSamplerBorderColor& args) { |
| 702 RGBA rgba; | 707 RGBA rgba; |
| 703 rgba.red = args.red; | 708 rgba.red = args.red; |
| 704 rgba.green = args.green; | 709 rgba.green = args.green; |
| 705 rgba.blue = args.blue; | 710 rgba.blue = args.blue; |
| 706 rgba.alpha = args.alpha; | 711 rgba.alpha = args.alpha; |
| 707 return gapi_->SetSamplerBorderColor(args.id, rgba); | 712 return gapi_->SetSamplerBorderColor(args.sampler_id, rgba); |
| 708 } | 713 } |
| 709 | 714 |
| 710 BufferSyncInterface::ParseError GAPIDecoder::HandleSetSamplerTexture( | 715 BufferSyncInterface::ParseError GAPIDecoder::HandleSetSamplerTexture( |
| 711 uint32 arg_count, | 716 uint32 arg_count, |
| 712 const cmd::SetSamplerTexture& args) { | 717 const cmd::SetSamplerTexture& args) { |
| 713 return gapi_->SetSamplerTexture(args.id, args.texture_id); | 718 return gapi_->SetSamplerTexture(args.sampler_id, args.texture_id); |
| 714 } | 719 } |
| 715 | 720 |
| 716 BufferSyncInterface::ParseError GAPIDecoder::HandleSetScissor( | 721 BufferSyncInterface::ParseError GAPIDecoder::HandleSetScissor( |
| 717 uint32 arg_count, | 722 uint32 arg_count, |
| 718 const cmd::SetScissor& args) { | 723 const cmd::SetScissor& args) { |
| 719 namespace cmd = set_scissor; | 724 Uint32 x_y_enable = args.x_y_enable; |
| 720 Uint32 x_y_enable = args.fixme0; | 725 if (cmd::SetScissor::Unused::Get(x_y_enable) != 0) |
| 721 if (cmd::Unused::Get(x_y_enable) != 0) | |
| 722 return BufferSyncInterface::kParseInvalidArguments; | 726 return BufferSyncInterface::kParseInvalidArguments; |
| 723 unsigned int x = cmd::X::Get(x_y_enable); | 727 unsigned int x = cmd::SetScissor::X::Get(x_y_enable); |
| 724 unsigned int y = cmd::Y::Get(x_y_enable); | 728 unsigned int y = cmd::SetScissor::Y::Get(x_y_enable); |
| 725 bool enable = cmd::Enable::Get(x_y_enable) != 0; | 729 bool enable = cmd::SetScissor::Enable::Get(x_y_enable) != 0; |
| 726 Uint32 width_height = args.fixme1; | 730 Uint32 width_height = args.width_height; |
| 727 unsigned int width = cmd::Width::Get(width_height); | 731 unsigned int width = cmd::SetScissor::Width::Get(width_height); |
| 728 unsigned int height = cmd::Height::Get(width_height); | 732 unsigned int height = cmd::SetScissor::Height::Get(width_height); |
| 729 gapi_->SetScissor(enable, x, y, width, height); | 733 gapi_->SetScissor(enable, x, y, width, height); |
| 730 return BufferSyncInterface::kParseNoError; | 734 return BufferSyncInterface::kParseNoError; |
| 731 } | 735 } |
| 732 | 736 |
| 733 BufferSyncInterface::ParseError GAPIDecoder::HandleSetPolygonOffset( | 737 BufferSyncInterface::ParseError GAPIDecoder::HandleSetPolygonOffset( |
| 734 uint32 arg_count, | 738 uint32 arg_count, |
| 735 const cmd::SetPolygonOffset& args) { | 739 const cmd::SetPolygonOffset& args) { |
| 736 gapi_->SetPolygonOffset(args.slope_factor, args.units); | 740 gapi_->SetPolygonOffset(args.slope_factor, args.units); |
| 737 return BufferSyncInterface::kParseNoError; | 741 return BufferSyncInterface::kParseNoError; |
| 738 } | 742 } |
| 739 | 743 |
| 740 BufferSyncInterface::ParseError GAPIDecoder::HandleSetPointLineRaster( | 744 BufferSyncInterface::ParseError GAPIDecoder::HandleSetPointLineRaster( |
| 741 uint32 arg_count, | 745 uint32 arg_count, |
| 742 const cmd::SetPointLineRaster& args) { | 746 const cmd::SetPointLineRaster& args) { |
| 743 namespace cmd = set_point_line_raster; | 747 Uint32 enables = args.enables; |
| 744 Uint32 enables = args.fixme0; | 748 if (cmd::SetPointLineRaster::Unused::Get(enables) != 0) |
| 745 if (cmd::Unused::Get(enables) != 0) | |
| 746 return BufferSyncInterface::kParseInvalidArguments; | 749 return BufferSyncInterface::kParseInvalidArguments; |
| 747 bool line_smooth = !!cmd::LineSmoothEnable::Get(enables); | 750 bool line_smooth = !!cmd::SetPointLineRaster::LineSmoothEnable::Get(enables); |
| 748 bool point_sprite = !!cmd::PointSpriteEnable::Get(enables); | 751 bool point_sprite = |
| 752 !!cmd::SetPointLineRaster::PointSpriteEnable::Get(enables); |
| 749 gapi_->SetPointLineRaster(line_smooth, point_sprite, args.point_size); | 753 gapi_->SetPointLineRaster(line_smooth, point_sprite, args.point_size); |
| 750 return BufferSyncInterface::kParseNoError; | 754 return BufferSyncInterface::kParseNoError; |
| 751 } | 755 } |
| 752 | 756 |
| 753 BufferSyncInterface::ParseError GAPIDecoder::HandleSetPolygonRaster( | 757 BufferSyncInterface::ParseError GAPIDecoder::HandleSetPolygonRaster( |
| 754 uint32 arg_count, | 758 uint32 arg_count, |
| 755 const cmd::SetPolygonRaster& args) { | 759 const cmd::SetPolygonRaster& args) { |
| 756 namespace cmd = set_polygon_raster; | 760 Uint32 fill_cull = args.fill_cull; |
| 757 Uint32 fill_cull = args.fixme0; | 761 unsigned int fill_value = cmd::SetPolygonRaster::FillMode::Get(fill_cull); |
| 758 unsigned int fill_value = cmd::FillMode::Get(fill_cull); | 762 unsigned int cull_value = cmd::SetPolygonRaster::CullMode::Get(fill_cull); |
| 759 unsigned int cull_value = cmd::CullMode::Get(fill_cull); | 763 if (cmd::SetPolygonRaster::Unused::Get(fill_cull) != 0 || |
| 760 if (cmd::Unused::Get(fill_cull) != 0 || | 764 fill_value >= command_buffer::kNumPolygonMode || |
| 761 fill_value >= GAPIInterface::NUM_POLYGON_MODE || | 765 cull_value >= command_buffer::kNumFaceCullMode) |
| 762 cull_value >= GAPIInterface::NUM_FACE_CULL_MODE) | |
| 763 return BufferSyncInterface::kParseInvalidArguments; | 766 return BufferSyncInterface::kParseInvalidArguments; |
| 764 gapi_->SetPolygonRaster( | 767 gapi_->SetPolygonRaster( |
| 765 static_cast<GAPIInterface::PolygonMode>(fill_value), | 768 static_cast<command_buffer::PolygonMode>(fill_value), |
| 766 static_cast<GAPIInterface::FaceCullMode>(cull_value)); | 769 static_cast<command_buffer::FaceCullMode>(cull_value)); |
| 767 return BufferSyncInterface::kParseNoError; | 770 return BufferSyncInterface::kParseNoError; |
| 768 } | 771 } |
| 769 | 772 |
| 770 BufferSyncInterface::ParseError GAPIDecoder::HandleSetAlphaTest( | 773 BufferSyncInterface::ParseError GAPIDecoder::HandleSetAlphaTest( |
| 771 uint32 arg_count, | 774 uint32 arg_count, |
| 772 const cmd::SetAlphaTest& args) { | 775 const cmd::SetAlphaTest& args) { |
| 773 namespace cmd = set_alpha_test; | 776 Uint32 func_enable = args.func_enable; |
| 774 Uint32 func_enable = args.fixme0; | 777 if (cmd::SetAlphaTest::Unused::Get(func_enable) != 0) |
| 775 if (cmd::Unused::Get(func_enable) != 0) | |
| 776 return BufferSyncInterface::kParseInvalidArguments; | 778 return BufferSyncInterface::kParseInvalidArguments; |
| 777 // Check that the bitmask get cannot generate values outside of the | 779 // Check that the bitmask get cannot generate values outside of the |
| 778 // allowed range. | 780 // allowed range. |
| 779 COMPILE_ASSERT(cmd::Func::kMask < GAPIInterface::NUM_COMPARISON, | 781 COMPILE_ASSERT(cmd::SetAlphaTest::Func::kMask < |
| 782 command_buffer::kNumComparison, |
| 780 set_alpha_test_Func_may_produce_invalid_values); | 783 set_alpha_test_Func_may_produce_invalid_values); |
| 781 GAPIInterface::Comparison comp = | 784 command_buffer::Comparison comp = static_cast<command_buffer::Comparison>( |
| 782 static_cast<GAPIInterface::Comparison>(cmd::Func::Get(func_enable)); | 785 cmd::SetAlphaTest::Func::Get(func_enable)); |
| 783 bool enable = cmd::Enable::Get(func_enable) != 0; | 786 bool enable = cmd::SetAlphaTest::Enable::Get(func_enable) != 0; |
| 784 gapi_->SetAlphaTest(enable, args.value, comp); | 787 gapi_->SetAlphaTest(enable, args.value, comp); |
| 785 return BufferSyncInterface::kParseNoError; | 788 return BufferSyncInterface::kParseNoError; |
| 786 } | 789 } |
| 787 | 790 |
| 788 BufferSyncInterface::ParseError GAPIDecoder::HandleSetDepthTest( | 791 BufferSyncInterface::ParseError GAPIDecoder::HandleSetDepthTest( |
| 789 uint32 arg_count, | 792 uint32 arg_count, |
| 790 const cmd::SetDepthTest& args) { | 793 const cmd::SetDepthTest& args) { |
| 791 namespace cmd = set_depth_test; | 794 Uint32 func_enable = args.func_enable; |
| 792 Uint32 func_enable = args.fixme0; | 795 if (cmd::SetDepthTest::Unused::Get(func_enable) != 0) |
| 793 if (cmd::Unused::Get(func_enable) != 0) | |
| 794 return BufferSyncInterface::kParseInvalidArguments; | 796 return BufferSyncInterface::kParseInvalidArguments; |
| 795 // Check that the bitmask get cannot generate values outside of the | 797 // Check that the bitmask get cannot generate values outside of the |
| 796 // allowed range. | 798 // allowed range. |
| 797 COMPILE_ASSERT(cmd::Func::kMask < GAPIInterface::NUM_COMPARISON, | 799 COMPILE_ASSERT(cmd::SetDepthTest::Func::kMask < |
| 800 command_buffer::kNumComparison, |
| 798 set_alpha_test_Func_may_produce_invalid_values); | 801 set_alpha_test_Func_may_produce_invalid_values); |
| 799 GAPIInterface::Comparison comp = | 802 command_buffer::Comparison comp = static_cast<command_buffer::Comparison>( |
| 800 static_cast<GAPIInterface::Comparison>(cmd::Func::Get(func_enable)); | 803 cmd::SetDepthTest::Func::Get(func_enable)); |
| 801 bool write_enable = cmd::WriteEnable::Get(func_enable) != 0; | 804 bool write_enable = cmd::SetDepthTest::WriteEnable::Get(func_enable) != 0; |
| 802 bool enable = cmd::Enable::Get(func_enable) != 0; | 805 bool enable = cmd::SetDepthTest::Enable::Get(func_enable) != 0; |
| 803 gapi_->SetDepthTest(enable, write_enable, comp); | 806 gapi_->SetDepthTest(enable, write_enable, comp); |
| 804 return BufferSyncInterface::kParseNoError; | 807 return BufferSyncInterface::kParseNoError; |
| 805 } | 808 } |
| 806 | 809 |
| 807 BufferSyncInterface::ParseError GAPIDecoder::HandleSetStencilTest( | 810 BufferSyncInterface::ParseError GAPIDecoder::HandleSetStencilTest( |
| 808 uint32 arg_count, | 811 uint32 arg_count, |
| 809 const cmd::SetStencilTest& args) { | 812 const cmd::SetStencilTest& args) { |
| 810 namespace cmd = set_stencil_test; | 813 Uint32 arg0 = args.stencil_args0; |
| 811 Uint32 arg0 = args.fixme0; | 814 Uint32 arg1 = args.stencil_args1; |
| 812 Uint32 arg1 = args.fixme1; | 815 if (cmd::SetStencilTest::Unused0::Get(arg0) != 0 || |
| 813 if (cmd::Unused0::Get(arg0) != 0 || | 816 cmd::SetStencilTest::Unused1::Get(arg1) != 0 || |
| 814 cmd::Unused1::Get(arg1) != 0 || | 817 cmd::SetStencilTest::Unused2::Get(arg1) != 0) |
| 815 cmd::Unused2::Get(arg1) != 0) | |
| 816 return BufferSyncInterface::kParseInvalidArguments; | 818 return BufferSyncInterface::kParseInvalidArguments; |
| 817 unsigned int write_mask = cmd::WriteMask::Get(arg0); | 819 unsigned int write_mask = cmd::SetStencilTest::WriteMask::Get(arg0); |
| 818 unsigned int compare_mask = cmd::CompareMask::Get(arg0); | 820 unsigned int compare_mask = cmd::SetStencilTest::CompareMask::Get(arg0); |
| 819 unsigned int ref = cmd::ReferenceValue::Get(arg0); | 821 unsigned int ref = cmd::SetStencilTest::ReferenceValue::Get(arg0); |
| 820 bool enable = cmd::Enable::Get(arg0) != 0; | 822 bool enable = cmd::SetStencilTest::Enable::Get(arg0) != 0; |
| 821 bool separate_ccw = cmd::SeparateCCW::Get(arg0) != 0; | 823 bool separate_ccw = cmd::SetStencilTest::SeparateCCW::Get(arg0) != 0; |
| 822 gapi_->SetStencilTest(enable, separate_ccw, write_mask, compare_mask, ref, | 824 gapi_->SetStencilTest(enable, separate_ccw, write_mask, compare_mask, ref, |
| 823 arg1); | 825 arg1); |
| 824 return BufferSyncInterface::kParseNoError; | 826 return BufferSyncInterface::kParseNoError; |
| 825 } | 827 } |
| 826 | 828 |
| 827 BufferSyncInterface::ParseError GAPIDecoder::HandleSetColorWrite( | 829 BufferSyncInterface::ParseError GAPIDecoder::HandleSetColorWrite( |
| 828 uint32 arg_count, | 830 uint32 arg_count, |
| 829 const cmd::SetColorWrite& args) { | 831 const cmd::SetColorWrite& args) { |
| 830 namespace cmd = set_color_write; | |
| 831 Uint32 enables = args.flags; | 832 Uint32 enables = args.flags; |
| 832 if (cmd::Unused::Get(enables) != 0) | 833 if (cmd::SetColorWrite::Unused::Get(enables) != 0) |
| 833 return BufferSyncInterface::kParseInvalidArguments; | 834 return BufferSyncInterface::kParseInvalidArguments; |
| 834 bool red = cmd::RedMask::Get(enables) != 0; | 835 bool red = cmd::SetColorWrite::RedMask::Get(enables) != 0; |
| 835 bool green = cmd::GreenMask::Get(enables) != 0; | 836 bool green = cmd::SetColorWrite::GreenMask::Get(enables) != 0; |
| 836 bool blue = cmd::BlueMask::Get(enables) != 0; | 837 bool blue = cmd::SetColorWrite::BlueMask::Get(enables) != 0; |
| 837 bool alpha = cmd::AlphaMask::Get(enables) != 0; | 838 bool alpha = cmd::SetColorWrite::AlphaMask::Get(enables) != 0; |
| 838 bool dither = cmd::DitherEnable::Get(enables) != 0; | 839 bool dither = cmd::SetColorWrite::DitherEnable::Get(enables) != 0; |
| 839 gapi_->SetColorWrite(red, green, blue, alpha, dither); | 840 gapi_->SetColorWrite(red, green, blue, alpha, dither); |
| 840 return BufferSyncInterface::kParseNoError; | 841 return BufferSyncInterface::kParseNoError; |
| 841 } | 842 } |
| 842 | 843 |
| 843 BufferSyncInterface::ParseError GAPIDecoder::HandleSetBlending( | 844 BufferSyncInterface::ParseError GAPIDecoder::HandleSetBlending( |
| 844 uint32 arg_count, | 845 uint32 arg_count, |
| 845 const cmd::SetBlending& args) { | 846 const cmd::SetBlending& args) { |
| 846 namespace cmd = set_blending; | 847 Uint32 arg = args.blend_settings; |
| 847 Uint32 arg = args.fixme0; | 848 bool enable = cmd::SetBlending::Enable::Get(arg) != 0; |
| 848 bool enable = cmd::Enable::Get(arg) != 0; | 849 bool separate_alpha = cmd::SetBlending::SeparateAlpha::Get(arg) != 0; |
| 849 bool separate_alpha = cmd::SeparateAlpha::Get(arg) != 0; | 850 unsigned int color_eq = cmd::SetBlending::ColorEq::Get(arg); |
| 850 unsigned int color_eq = cmd::ColorEq::Get(arg); | 851 unsigned int color_src = cmd::SetBlending::ColorSrcFunc::Get(arg); |
| 851 unsigned int color_src = cmd::ColorSrcFunc::Get(arg); | 852 unsigned int color_dst = cmd::SetBlending::ColorDstFunc::Get(arg); |
| 852 unsigned int color_dst = cmd::ColorDstFunc::Get(arg); | 853 unsigned int alpha_eq = cmd::SetBlending::AlphaEq::Get(arg); |
| 853 unsigned int alpha_eq = cmd::AlphaEq::Get(arg); | 854 unsigned int alpha_src = cmd::SetBlending::AlphaSrcFunc::Get(arg); |
| 854 unsigned int alpha_src = cmd::AlphaSrcFunc::Get(arg); | 855 unsigned int alpha_dst = cmd::SetBlending::AlphaDstFunc::Get(arg); |
| 855 unsigned int alpha_dst = cmd::AlphaDstFunc::Get(arg); | 856 if (cmd::SetBlending::Unused0::Get(arg) != 0 || |
| 856 if (cmd::Unused0::Get(arg) != 0 || | 857 cmd::SetBlending::Unused1::Get(arg) != 0 || |
| 857 cmd::Unused1::Get(arg) != 0 || | 858 color_eq >= command_buffer::kNumBlendEq || |
| 858 color_eq >= GAPIInterface::NUM_BLEND_EQ || | 859 color_src >= command_buffer::kNumBlendFunc || |
| 859 color_src >= GAPIInterface::NUM_BLEND_FUNC || | 860 color_dst >= command_buffer::kNumBlendFunc || |
| 860 color_dst >= GAPIInterface::NUM_BLEND_FUNC || | 861 alpha_eq >= command_buffer::kNumBlendEq || |
| 861 alpha_eq >= GAPIInterface::NUM_BLEND_EQ || | 862 alpha_src >= command_buffer::kNumBlendFunc || |
| 862 alpha_src >= GAPIInterface::NUM_BLEND_FUNC || | 863 alpha_dst >= command_buffer::kNumBlendFunc) |
| 863 alpha_dst >= GAPIInterface::NUM_BLEND_FUNC) | |
| 864 return BufferSyncInterface::kParseInvalidArguments; | 864 return BufferSyncInterface::kParseInvalidArguments; |
| 865 gapi_->SetBlending(enable, | 865 gapi_->SetBlending(enable, |
| 866 separate_alpha, | 866 separate_alpha, |
| 867 static_cast<GAPIInterface::BlendEq>(color_eq), | 867 static_cast<command_buffer::BlendEq>(color_eq), |
| 868 static_cast<GAPIInterface::BlendFunc>(color_src), | 868 static_cast<command_buffer::BlendFunc>(color_src), |
| 869 static_cast<GAPIInterface::BlendFunc>(color_dst), | 869 static_cast<command_buffer::BlendFunc>(color_dst), |
| 870 static_cast<GAPIInterface::BlendEq>(alpha_eq), | 870 static_cast<command_buffer::BlendEq>(alpha_eq), |
| 871 static_cast<GAPIInterface::BlendFunc>(alpha_src), | 871 static_cast<command_buffer::BlendFunc>(alpha_src), |
| 872 static_cast<GAPIInterface::BlendFunc>(alpha_dst)); | 872 static_cast<command_buffer::BlendFunc>(alpha_dst)); |
| 873 return BufferSyncInterface::kParseNoError; | 873 return BufferSyncInterface::kParseNoError; |
| 874 } | 874 } |
| 875 | 875 |
| 876 BufferSyncInterface::ParseError GAPIDecoder::HandleSetBlendingColor( | 876 BufferSyncInterface::ParseError GAPIDecoder::HandleSetBlendingColor( |
| 877 uint32 arg_count, | 877 uint32 arg_count, |
| 878 const cmd::SetBlendingColor& args) { | 878 const cmd::SetBlendingColor& args) { |
| 879 RGBA rgba; | 879 RGBA rgba; |
| 880 rgba.red = args.red; | 880 rgba.red = args.red; |
| 881 rgba.green = args.green; | 881 rgba.green = args.green; |
| 882 rgba.blue = args.blue; | 882 rgba.blue = args.blue; |
| 883 rgba.alpha = args.alpha; | 883 rgba.alpha = args.alpha; |
| 884 gapi_->SetBlendingColor(rgba); | 884 gapi_->SetBlendingColor(rgba); |
| 885 return BufferSyncInterface::kParseNoError; | 885 return BufferSyncInterface::kParseNoError; |
| 886 } | 886 } |
| 887 | 887 |
| 888 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateRenderSurface( | 888 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateRenderSurface( |
| 889 uint32 arg_count, | 889 uint32 arg_count, |
| 890 const cmd::CreateRenderSurface& args) { | 890 const cmd::CreateRenderSurface& args) { |
| 891 namespace cmd = create_render_surface_cmd; | 891 unsigned int width_height = args.width_height; |
| 892 unsigned int width_height = args.fixme1; | 892 unsigned int width = cmd::CreateRenderSurface::Width::Get(width_height); |
| 893 unsigned int width = cmd::Width::Get(width_height); | 893 unsigned int height = cmd::CreateRenderSurface::Height::Get(width_height); |
| 894 unsigned int height = cmd::Height::Get(width_height); | 894 unsigned int levels_side = args.levels_side; |
| 895 unsigned int levels_side = args.fixme2; | 895 unsigned int mip_level = cmd::CreateRenderSurface::Levels::Get(levels_side); |
| 896 unsigned int mip_level = cmd::Levels::Get(levels_side); | 896 unsigned int side = cmd::CreateRenderSurface::Side::Get(levels_side); |
| 897 unsigned int side = cmd::Side::Get(levels_side); | 897 return gapi_->CreateRenderSurface(args.render_surface_id, |
| 898 return gapi_->CreateRenderSurface(args.id, width, height, mip_level, | 898 width, height, mip_level, |
| 899 side, args.texture_id); | 899 side, args.texture_id); |
| 900 } | 900 } |
| 901 | 901 |
| 902 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyRenderSurface( | 902 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyRenderSurface( |
| 903 uint32 arg_count, | 903 uint32 arg_count, |
| 904 const cmd::DestroyRenderSurface& args) { | 904 const cmd::DestroyRenderSurface& args) { |
| 905 return gapi_->DestroyRenderSurface(args.id); | 905 return gapi_->DestroyRenderSurface(args.render_surface_id); |
| 906 } | 906 } |
| 907 | 907 |
| 908 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateDepthSurface( | 908 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateDepthSurface( |
| 909 uint32 arg_count, | 909 uint32 arg_count, |
| 910 const cmd::CreateDepthSurface& args) { | 910 const cmd::CreateDepthSurface& args) { |
| 911 namespace cmd = create_depth_surface_cmd; | 911 unsigned int width_height = args.width_height; |
| 912 unsigned int width_height = args.fixme1; | 912 unsigned int width = cmd::CreateDepthSurface::Width::Get(width_height); |
| 913 unsigned int width = cmd::Width::Get(width_height); | 913 unsigned int height = cmd::CreateDepthSurface::Height::Get(width_height); |
| 914 unsigned int height = cmd::Height::Get(width_height); | 914 return gapi_->CreateDepthSurface(args.depth_surface_id, width, height); |
| 915 return gapi_->CreateDepthSurface(args.id, width, height); | |
| 916 } | 915 } |
| 917 | 916 |
| 918 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyDepthSurface( | 917 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyDepthSurface( |
| 919 uint32 arg_count, | 918 uint32 arg_count, |
| 920 const cmd::DestroyDepthSurface& args) { | 919 const cmd::DestroyDepthSurface& args) { |
| 921 return gapi_->DestroyDepthSurface(args.id); | 920 return gapi_->DestroyDepthSurface(args.depth_surface_id); |
| 922 } | 921 } |
| 923 | 922 |
| 924 BufferSyncInterface::ParseError GAPIDecoder::HandleSetRenderSurface( | 923 BufferSyncInterface::ParseError GAPIDecoder::HandleSetRenderSurface( |
| 925 uint32 arg_count, | 924 uint32 arg_count, |
| 926 const cmd::SetRenderSurface& args) { | 925 const cmd::SetRenderSurface& args) { |
| 927 return gapi_->SetRenderSurface(args.render_surface_id, args.depth_surface_id); | 926 return gapi_->SetRenderSurface(args.render_surface_id, args.depth_surface_id); |
| 928 } | 927 } |
| 929 | 928 |
| 930 BufferSyncInterface::ParseError GAPIDecoder::HandleSetBackSurfaces( | 929 BufferSyncInterface::ParseError GAPIDecoder::HandleSetBackSurfaces( |
| 931 uint32 arg_count, | 930 uint32 arg_count, |
| 932 const cmd::SetBackSurfaces& args) { | 931 const cmd::SetBackSurfaces& args) { |
| 933 gapi_->SetBackSurfaces(); | 932 gapi_->SetBackSurfaces(); |
| 934 return BufferSyncInterface::kParseNoError; | 933 return BufferSyncInterface::kParseNoError; |
| 935 } | 934 } |
| 936 | 935 |
| 937 } // namespace command_buffer | 936 } // namespace command_buffer |
| 938 } // namespace o3d | 937 } // namespace o3d |
| OLD | NEW |