| 1 |
/* |
| 2 |
* Copyright (c) 2017-2021, Intel Corporation |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 5 |
* copy of this software and associated documentation files (the "Software"), |
| 6 |
* to deal in the Software without restriction, including without limitation |
| 7 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 9 |
* Software is furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be included |
| 12 |
* in all copies or substantial portions of the Software. |
| 13 |
* |
| 14 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 |
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 |
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 21 |
*/ |
| 22 |
//! |
| 23 |
//! \file cm_wrapper.cpp |
| 24 |
//! \brief Contains implementations of OS-agnostic functions for executing |
| 25 |
//! commands from cmrtlib. |
| 26 |
//! |
| 27 |
|
| 28 |
#include "cm_wrapper.h" |
| 29 |
|
| 30 |
#include "cm_device_rt.h" |
| 31 |
#include "cm_hal.h" |
| 32 |
#include "cm_kernel_rt.h" |
| 33 |
#include "cm_program.h" |
| 34 |
#include "cm_task_rt.h" |
| 35 |
#include "cm_thread_space_rt.h" |
| 36 |
#include "cm_group_space.h" |
| 37 |
#include "cm_queue_rt.h" |
| 38 |
#include "cm_sampler.h" |
| 39 |
#include "cm_sampler8x8.h" |
| 40 |
#include "cm_surface_2d_rt.h" |
| 41 |
#include "cm_vebox_rt.h" |
| 42 |
#include "cm_extension_creator.h" |
| 43 |
|
| 44 |
#if USE_EXTENSION_CODE |
| 45 |
#include "cm_gtpin.h" |
| 46 |
#endif |
| 47 |
|
| 48 |
using CMRT_UMD::CmWrapperEx; |
| 49 |
static bool cmWrapperExRegistered = CmExtensionCreator<CmWrapperEx>::RegisterClass<CmWrapperEx>(); |
| 50 |
|
| 51 |
struct CM_ENQUEUE_GPUCOPY_PARAM |
| 52 |
{ |
| 53 |
void *queueHandle; // [in] CmQueue pointer in CMRT@UMD |
| 54 |
void *surface2d; // [in] CmSurface2d pointer in CMRT@UMD |
| 55 |
void *sysMem; // [in] pointer of system memory |
| 56 |
CM_GPUCOPY_DIRECTION copyDir; // [in] direction for GPUCopy: CM_FASTCOPY_GPU2CPU (0) or CM_FASTCOPY_CPU2GPU(1) |
| 57 |
uint32_t widthStride; // [in] width stride in byte for system memory, ZERO means no setting |
| 58 |
uint32_t heightStride; // [in] height stride in row for system memory, ZERO means no setting |
| 59 |
uint32_t option; // [in] option passed by user, only support CM_FASTCOPY_OPTION_NONBLOCKING(0) and CM_FASTCOPY_OPTION_BLOCKING(1) |
| 60 |
void *eventHandle; // [in/out] return CmDevice pointer in CMRT@UMD, nullptr if the input is CM_NO_EVENT |
| 61 |
uint32_t eventIndex; // [out] index of Event in m_EventArray |
| 62 |
int32_t returnValue; // [out] return value from CMRT@UMD |
| 63 |
}; |
| 64 |
|
| 65 |
struct CM_CREATEBUFFER_PARAM |
| 66 |
{ |
| 67 |
size_t size; // [in] buffer size in byte |
| 68 |
CM_BUFFER_TYPE bufferType; // [in] Buffer type (Buffer, BufferUP, or Buffer SVM) |
| 69 |
void *sysMem; // [in] Address of system memory |
| 70 |
void *bufferHandle; // [out] pointer to CmBuffer object in CMRT@UMD |
| 71 |
int32_t returnValue; // [out] the return value from CMRT@UMD |
| 72 |
uint32_t option; |
| 73 |
}; |
| 74 |
|
| 75 |
namespace CMRT_UMD |
| 76 |
{ |
| 77 |
void CmWrapperEx::Initialize(void *context) |
| 78 |
{ |
| 79 |
UNUSED(context); |
| 80 |
} |
| 81 |
|
| 82 |
int CmWrapperEx::Execute( |
| 83 |
CmDevice *device, |
| 84 |
CM_FUNCTION_ID cmFunctionID, |
| 85 |
void *inputData, |
| 86 |
uint32_t inputDataLen) |
| 87 |
{ |
| 88 |
UNUSED(device); |
| 89 |
UNUSED(cmFunctionID); |
| 90 |
UNUSED(inputData); |
| 91 |
UNUSED(inputDataLen); |
| 92 |
|
| 93 |
// currently, there is no extended functionality in this class |
| 94 |
// This interface is for future usage |
| 95 |
CM_ASSERTMESSAGE("Error: Invalid Function code '0x%x'.", cmFunctionID); |
| 96 |
// since there is no extended functionality now, it should return invalid function ID because |
| 97 |
// the function ID is not supported for now |
| 98 |
return CM_INVALID_PRIVATE_DATA; |
| 99 |
} |
| 100 |
}; |
| 101 |
|
| 102 |
//*----------------------------------------------------------------------------- |
| 103 |
//| Purpose: Get Time in ms and used in performance measurement |
| 104 |
//| Returns: Current system time. |
| 105 |
//*----------------------------------------------------------------------------- |
| 106 |
double CmGetTimeInms() |
| 107 |
{ |
| 108 |
LARGE_INTEGER freq; |
| 109 |
LARGE_INTEGER count; |
| 110 |
double curTime; |
| 111 |
|
| 112 |
MosUtilities::MosQueryPerformanceFrequency((uint64_t *)&freq.QuadPart); |
| 113 |
MosUtilities::MosQueryPerformanceCounter((uint64_t *)&count.QuadPart); |
| 114 |
curTime = (double)(1000.0 * count.QuadPart/(double)freq.QuadPart); |
| 115 |
|
| 116 |
return curTime; |
| 117 |
} |
| 118 |
|
| 119 |
#define CM_SET_NOFAILURE_STATUS(hr) \ |
| 120 |
if (hr != CM_FAILURE) \ |
| 121 |
{ \ |
| 122 |
hr = CM_SUCCESS; \ |
| 123 |
} |
| 124 |
|
| 125 |
#if USE_EXTENSION_CODE |
| 126 |
extern int CmThinExecuteEnableGTPin(CmDevice *device, void *cmPrivateInputData); |
| 127 |
extern int CmThinExecuteRegGTPinMarkers(CmDevice *device, void *cmPrivateInputData); |
| 128 |
#endif |
| 129 |
|
| 130 |
using CMRT_UMD::CmSurface2D; |
| 131 |
using CMRT_UMD::CmSurface2DRT; |
| 132 |
using CMRT_UMD::SurfaceIndex; |
| 133 |
using CMRT_UMD::CmDeviceRT; |
| 134 |
using CMRT_UMD::CmDeviceRTBase; |
| 135 |
using CMRT_UMD::CmBuffer; |
| 136 |
using CMRT_UMD::CmBufferUP; |
| 137 |
using CMRT_UMD::CmBufferSVM; |
| 138 |
using CMRT_UMD::CmSurface2DUP; |
| 139 |
using CMRT_UMD::CmKernel; |
| 140 |
using CMRT_UMD::CmKernelRT; |
| 141 |
using CMRT_UMD::CmProgram; |
| 142 |
using CMRT_UMD::CmProgramRT; |
| 143 |
using CMRT_UMD::CmTask; |
| 144 |
using CMRT_UMD::CmTaskRT; |
| 145 |
using CMRT_UMD::CmQueue; |
| 146 |
using CMRT_UMD::CmQueueRT; |
| 147 |
using CMRT_UMD::CmThreadSpace; |
| 148 |
using CMRT_UMD::CmThreadGroupSpace; |
| 149 |
using CMRT_UMD::CmEvent; |
| 150 |
using CMRT_UMD::CmThreadSpaceRT; |
| 151 |
using CMRT_UMD::CmSampler; |
| 152 |
using CMRT_UMD::CmVebox; |
| 153 |
using CMRT_UMD::CmVeboxRT; |
| 154 |
using CMRT_UMD::CmSurface3D; |
| 155 |
using CMRT_UMD::CmSampler8x8; |
| 156 |
using CMRT_UMD::CmBufferStateless; |
| 157 |
//*----------------------------------------------------------------------------- |
| 158 |
//| Purpose: CMRT thin layer library supported function execution |
| 159 |
//| Return: CM_SUCCESS if successful |
| 160 |
//*----------------------------------------------------------------------------- |
| 161 |
int32_t CmThinExecuteInternal(CmDevice *device, |
| 162 |
CM_FUNCTION_ID cmFunctionID, |
| 163 |
void *cmPrivateInputData, |
| 164 |
uint32_t cmPrivateInputDataSize) |
| 165 |
{ |
| 166 |
int32_t hr = CM_SUCCESS; |
| 167 |
int32_t cmRet = CM_INVALID_PRIVATE_DATA; |
| 168 |
CmBuffer *cmBuffer = nullptr; |
| 169 |
CmBufferUP *cmBufferUP = nullptr; |
| 170 |
CmBufferSVM *cmBufferSVM = nullptr; |
| 171 |
CmBufferStateless *cmBufferStateless = nullptr; |
| 172 |
CmSurface2DRT *cmSurface2d = nullptr; |
| 173 |
CmSurface2DUP *cmSurface2dup = nullptr; |
| 174 |
CmProgram *cmProgram = nullptr; |
| 175 |
CmKernel *cmKernel = nullptr; |
| 176 |
CmTask *cmTask = nullptr; |
| 177 |
CmQueue *cmQueue = nullptr; |
| 178 |
CmQueueRT *cmQueueRT = nullptr; |
| 179 |
CmEvent *cmEvent = nullptr; |
| 180 |
CmThreadSpace *cmThreadSpace = nullptr; |
| 181 |
CmThreadGroupSpace *cmThreadGroupSpace = nullptr; |
| 182 |
SurfaceIndex *vmeSurIndex = nullptr; |
| 183 |
SurfaceIndex *surfaceIndex = nullptr; |
| 184 |
CmSampler *sampler = nullptr; |
| 185 |
CMRT_UMD::SamplerIndex *samplerIndex = nullptr; |
| 186 |
CmThreadGroupSpace *threadGrpSpace = nullptr; |
| 187 |
CmSurface3D *cmSurface3d = nullptr; |
| 188 |
CmSampler8x8 *sampler8x8 = nullptr; |
| 189 |
CmSurface2D *cmSrcSurface2d = nullptr; |
| 190 |
CmSurface2D *cmDstSurface2d = nullptr; |
| 191 |
CmSurface2D *cmSurf2DBase = nullptr; |
| 192 |
CmVebox *cmVebox = nullptr; |
| 193 |
CmDeviceRT *deviceRT = nullptr; |
| 194 |
CmDeviceRTBase *deviceRtBase = nullptr; |
| 195 |
|
| 196 |
if (cmPrivateInputData == nullptr) |
| 197 |
{ |
| 198 |
CM_ASSERTMESSAGE("Error: Null pointer."); |
| 199 |
return CM_INVALID_PRIVATE_DATA; |
| 200 |
} |
| 201 |
|
| 202 |
if ((cmFunctionID != CM_FN_RT_ULT_INFO && cmFunctionID != CM_FN_RT_ULT)&&(device == nullptr)) |
| 203 |
{ |
| 204 |
CM_ASSERTMESSAGE("Error: Null pointer."); |
| 205 |
return CM_NULL_POINTER; |
| 206 |
} |
| 207 |
deviceRT = static_cast<CmDeviceRT*>(device); |
| 208 |
deviceRtBase = static_cast<CmDeviceRTBase *>(device); |
| 209 |
|
| 210 |
switch(cmFunctionID) |
| 211 |
{ |
| 212 |
case CM_FN_CMDEVICE_CREATEBUFFER: |
| 213 |
if(cmPrivateInputDataSize == sizeof(CM_CREATEBUFFER_PARAM)) |
| 214 |
{ |
| 215 |
CM_CREATEBUFFER_PARAM *pCmBufferParam |
| 216 |
= (CM_CREATEBUFFER_PARAM*)(cmPrivateInputData); |
| 217 |
|
| 218 |
if(pCmBufferParam->bufferType == CM_BUFFER_N) |
| 219 |
{ |
| 220 |
//Create Buffer |
| 221 |
cmRet = device->CreateBuffer(pCmBufferParam->size, cmBuffer); |
| 222 |
//Create Surface Index |
| 223 |
if( cmRet == CM_SUCCESS) |
| 224 |
{ |
| 225 |
pCmBufferParam->bufferHandle = static_cast<CmBuffer *>(cmBuffer); |
| 226 |
} |
| 227 |
//Fill the output message |
| 228 |
pCmBufferParam->returnValue = cmRet; |
| 229 |
} |
| 230 |
else if(pCmBufferParam->bufferType == CM_BUFFER_UP) |
| 231 |
{ // Create Buffer Up |
| 232 |
cmRet = device->CreateBufferUP(pCmBufferParam->size, |
| 233 |
pCmBufferParam->sysMem, |
| 234 |
cmBufferUP); |
| 235 |
//Create Surface Index |
| 236 |
if( cmRet == CM_SUCCESS) |
| 237 |
{ |
| 238 |
pCmBufferParam->bufferHandle = cmBufferUP; |
| 239 |
} |
| 240 |
//Fill the output message |
| 241 |
pCmBufferParam->returnValue = cmRet; |
| 242 |
} |
| 243 |
else if (pCmBufferParam->bufferType == CM_BUFFER_SVM) |
| 244 |
{ |
| 245 |
cmRet = device->CreateBufferSVM(pCmBufferParam->size, |
| 246 |
pCmBufferParam->sysMem, |
| 247 |
0, |
| 248 |
cmBufferSVM); |
| 249 |
if (cmRet == CM_SUCCESS) |
| 250 |
{ |
| 251 |
pCmBufferParam->bufferHandle = cmBufferSVM; |
| 252 |
} |
| 253 |
//Fill the output message |
| 254 |
pCmBufferParam->returnValue = cmRet; |
| 255 |
} |
| 256 |
else if (pCmBufferParam->bufferType == CM_BUFFER_STATELESS) |
| 257 |
{ |
| 258 |
cmRet = deviceRtBase->CreateBufferStateless(pCmBufferParam->size, |
| 259 |
pCmBufferParam->option, |
| 260 |
pCmBufferParam->sysMem, |
| 261 |
cmBufferStateless); |
| 262 |
if (cmRet == CM_SUCCESS) |
| 263 |
{ |
| 264 |
pCmBufferParam->bufferHandle = cmBufferStateless; |
| 265 |
} |
| 266 |
//Fill the output message |
| 267 |
pCmBufferParam->returnValue = cmRet; |
| 268 |
} |
| 269 |
else //should never jump here |
| 270 |
{ |
| 271 |
pCmBufferParam->returnValue = CM_INVALID_ARG_VALUE; |
| 272 |
goto finish; |
| 273 |
} |
| 274 |
} |
| 275 |
else |
| 276 |
{ |
| 277 |
hr = CM_INVALID_PRIVATE_DATA; |
| 278 |
goto finish; |
| 279 |
} |
| 280 |
break; |
| 281 |
|
| 282 |
case CM_FN_CMDEVICE_DESTROYBUFFER: |
| 283 |
PCM_DESTROYBUFFER_PARAM cmDestBufferParam; |
| 284 |
cmDestBufferParam = (PCM_DESTROYBUFFER_PARAM)(cmPrivateInputData); |
| 285 |
|
| 286 |
cmBuffer = (CmBuffer *)(cmDestBufferParam->bufferHandle); |
| 287 |
CM_ASSERT(cmBuffer); |
| 288 |
|
| 289 |
cmRet = device->DestroySurface(cmBuffer); |
| 290 |
|
| 291 |
//Fill the output message |
| 292 |
cmDestBufferParam->returnValue = cmRet; |
| 293 |
break; |
| 294 |
|
| 295 |
case CM_FN_CMDEVICE_DESTROYBUFFERUP: |
| 296 |
PCM_DESTROYBUFFER_PARAM cmDestBufferUPParam; |
| 297 |
cmDestBufferUPParam = (PCM_DESTROYBUFFER_PARAM)(cmPrivateInputData); |
| 298 |
|
| 299 |
cmBufferUP= (CmBufferUP *)(cmDestBufferUPParam->bufferHandle); |
| 300 |
CM_ASSERT(cmBufferUP); |
| 301 |
|
| 302 |
cmRet = device->DestroyBufferUP(cmBufferUP); |
| 303 |
|
| 304 |
//Fill the output message |
| 305 |
cmDestBufferUPParam->returnValue = cmRet; |
| 306 |
break; |
| 307 |
|
| 308 |
case CM_FN_CMDEVICE_DESTROYBUFFERSVM: |
| 309 |
PCM_DESTROYBUFFER_PARAM cmDestBufferSVMParam; |
| 310 |
cmDestBufferSVMParam = (PCM_DESTROYBUFFER_PARAM)(cmPrivateInputData); |
| 311 |
|
| 312 |
cmBufferSVM = (CmBufferSVM *)(cmDestBufferSVMParam->bufferHandle); |
| 313 |
CM_ASSERT(cmBufferSVM); |
| 314 |
|
| 315 |
cmRet = device->DestroyBufferSVM(cmBufferSVM); |
| 316 |
//Fill the output message |
| 317 |
cmDestBufferSVMParam->returnValue = cmRet; |
| 318 |
break; |
| 319 |
|
| 320 |
case CM_FN_CMDEVICE_DESTROYBUFFERSTATELESS: |
| 321 |
PCM_DESTROYBUFFER_PARAM cmDestBufferStatelessParam; |
| 322 |
cmDestBufferStatelessParam = (PCM_DESTROYBUFFER_PARAM)(cmPrivateInputData); |
| 323 |
|
| 324 |
cmBufferStateless = |
| 325 |
static_cast<CmBufferStateless *>(cmDestBufferStatelessParam->bufferHandle); |
| 326 |
CM_ASSERT(cmBufferStateless); |
| 327 |
|
| 328 |
cmRet = deviceRtBase->DestroyBufferStateless(cmBufferStateless); |
| 329 |
//Fill the output message |
| 330 |
cmDestBufferStatelessParam->returnValue = cmRet; |
| 331 |
break; |
| 332 |
|
| 333 |
case CM_FN_CMDEVICE_DESTROYSURFACE2DUP: |
| 334 |
PCM_DESTROYSURFACE2DUP_PARAM cmDestroy2DUpParam; |
| 335 |
cmDestroy2DUpParam = (PCM_DESTROYSURFACE2DUP_PARAM)(cmPrivateInputData); |
| 336 |
cmSurface2dup = static_cast<CmSurface2DUP *>(cmDestroy2DUpParam->surface2DUPHandle); |
| 337 |
|
| 338 |
cmRet = device->DestroySurface2DUP(cmSurface2dup); |
| 339 |
|
| 340 |
cmDestroy2DUpParam->returnValue = cmRet; |
| 341 |
break; |
| 342 |
|
| 343 |
case CM_FN_CMDEVICE_CREATESURFACE2D_ALIAS: |
| 344 |
{ |
| 345 |
PCM_DEVICE_CREATE_SURF2D_ALIAS_PARAM createSurf2DAliasParam; |
| 346 |
createSurf2DAliasParam = (PCM_DEVICE_CREATE_SURF2D_ALIAS_PARAM)(cmPrivateInputData); |
| 347 |
CmSurface2D * cmSurfBase = static_cast<CmSurface2D *>(createSurf2DAliasParam->surface2DHandle); |
| 348 |
surfaceIndex = (SurfaceIndex*)createSurf2DAliasParam->surfaceIndexHandle; |
| 349 |
|
| 350 |
cmRet = device->CreateSurface2DAlias(cmSurfBase, surfaceIndex); |
| 351 |
createSurf2DAliasParam->surfaceIndexHandle = surfaceIndex; |
| 352 |
createSurf2DAliasParam->returnValue = cmRet; |
| 353 |
} |
| 354 |
break; |
| 355 |
|
| 356 |
case CM_FN_CMDEVICE_CREATEBUFFER_ALIAS: |
| 357 |
{ |
| 358 |
PCM_DEVICE_CREATE_BUFFER_ALIAS_PARAM createBufferAliasParam; |
| 359 |
createBufferAliasParam = (PCM_DEVICE_CREATE_BUFFER_ALIAS_PARAM)(cmPrivateInputData); |
| 360 |
cmBuffer= static_cast<CmBuffer *>(createBufferAliasParam->bufferHandle); |
| 361 |
surfaceIndex = (SurfaceIndex*)createBufferAliasParam->surfaceIndexHandle; |
| 362 |
|
| 363 |
cmRet = device->CreateBufferAlias(cmBuffer, surfaceIndex); |
| 364 |
createBufferAliasParam->surfaceIndexHandle = surfaceIndex; |
| 365 |
createBufferAliasParam->returnValue = cmRet; |
| 366 |
} |
| 367 |
break; |
| 368 |
|
| 369 |
case CM_FN_CMDEVICE_CLONEKERNEL: |
| 370 |
{ |
| 371 |
PCM_CLONE_KERNEL_PARAM cloneKernelParam; |
| 372 |
cloneKernelParam = (PCM_CLONE_KERNEL_PARAM)(cmPrivateInputData); |
| 373 |
CmKernel * kernelDest = static_cast<CmKernel *>(cloneKernelParam->kernelHandleDest); |
| 374 |
CmKernel * kernelSrc = static_cast<CmKernel *>(cloneKernelParam->kernelHandleSrc); |
| 375 |
cmRet = device->CloneKernel(kernelDest, kernelSrc); |
| 376 |
cloneKernelParam->kernelHandleDest = kernelDest; |
| 377 |
|
| 378 |
cloneKernelParam->returnValue = cmRet; |
| 379 |
} |
| 380 |
break; |
| 381 |
|
| 382 |
case CM_FN_CMDEVICE_DESTROYSURFACE2D: |
| 383 |
{ |
| 384 |
PCM_DESTROYSURFACE2D_PARAM cmDestroy2DParam; |
| 385 |
|
| 386 |
cmDestroy2DParam = (PCM_DESTROYSURFACE2D_PARAM)(cmPrivateInputData); |
| 387 |
CmSurface2D * cmSurfBase = (CmSurface2D *)(cmDestroy2DParam->surface2DHandle); |
| 388 |
|
| 389 |
CM_ASSERT(cmSurfBase); |
| 390 |
|
| 391 |
cmRet = device->DestroySurface(cmSurfBase); |
| 392 |
//Fill output message |
| 393 |
cmDestroy2DParam->surface2DHandle = nullptr; |
| 394 |
cmDestroy2DParam->returnValue = cmRet; |
| 395 |
} |
| 396 |
break; |
| 397 |
|
| 398 |
case CM_FN_CMDEVICE_LOADPROGRAM: |
| 399 |
PCM_LOADPROGRAM_PARAM cmLoadProgParam; |
| 400 |
cmLoadProgParam = (PCM_LOADPROGRAM_PARAM)(cmPrivateInputData); |
| 401 |
CM_ASSERT(cmLoadProgParam->cisaCode); |
| 402 |
|
| 403 |
cmRet = device->LoadProgram(cmLoadProgParam->cisaCode, |
| 404 |
cmLoadProgParam->cisaCodeSize, |
| 405 |
cmProgram, |
| 406 |
cmLoadProgParam->options); |
| 407 |
|
| 408 |
if(cmRet == CM_SUCCESS && cmProgram) |
| 409 |
{ |
| 410 |
cmLoadProgParam->programHandle = static_cast<CmProgram *>(cmProgram); |
| 411 |
CmProgramRT *cmProgramRT = static_cast<CmProgramRT *>(cmProgram); |
| 412 |
cmLoadProgParam->indexInArray = cmProgramRT->GetProgramIndex(); |
| 413 |
} |
| 414 |
cmLoadProgParam->returnValue = cmRet; |
| 415 |
break; |
| 416 |
|
| 417 |
case CM_FN_CMDEVICE_DESTROYPROGRAM: |
| 418 |
PCM_DESTROYPROGRAM_PARAM cmDestoyProgParam; |
| 419 |
cmDestoyProgParam = (PCM_DESTROYPROGRAM_PARAM)(cmPrivateInputData); |
| 420 |
cmProgram = (CmProgram *)(cmDestoyProgParam->programHandle); |
| 421 |
|
| 422 |
CM_ASSERT(cmProgram); |
| 423 |
|
| 424 |
cmRet = device->DestroyProgram(cmProgram); |
| 425 |
|
| 426 |
cmDestoyProgParam->returnValue = cmRet; |
| 427 |
break; |
| 428 |
|
| 429 |
case CM_FN_CMDEVICE_CREATEKERNEL: |
| 430 |
PCM_CREATEKERNEL_PARAM cmCreateKernelParam; |
| 431 |
cmCreateKernelParam =(PCM_CREATEKERNEL_PARAM)(cmPrivateInputData); |
| 432 |
cmProgram = (CmProgram *)(cmCreateKernelParam->programHandle); |
| 433 |
|
| 434 |
cmRet = device->CreateKernel(cmProgram, |
| 435 |
cmCreateKernelParam->kernelName, |
| 436 |
cmKernel, |
| 437 |
cmCreateKernelParam->options); |
| 438 |
if(cmRet == CM_SUCCESS && cmKernel) |
| 439 |
{ |
| 440 |
cmCreateKernelParam->kernelHandle = static_cast< CmKernel * >(cmKernel); |
| 441 |
CmKernelRT *kernelRT = static_cast<CmKernelRT *>(cmKernel); |
| 442 |
cmCreateKernelParam->indexKernelArray = kernelRT->GetKernelIndex(); |
| 443 |
} |
| 444 |
cmCreateKernelParam->returnValue = cmRet; |
| 445 |
break; |
| 446 |
|
| 447 |
case CM_FN_CMDEVICE_DESTROYKERNEL: |
| 448 |
PCM_DESTROYKERNEL_PARAM cmDestroyKernelParam; |
| 449 |
cmDestroyKernelParam = (PCM_DESTROYKERNEL_PARAM)(cmPrivateInputData); |
| 450 |
cmKernel =(CmKernel *)(cmDestroyKernelParam->kernelHandle); |
| 451 |
CM_ASSERT(cmKernel); |
| 452 |
|
| 453 |
cmRet = device->DestroyKernel(cmKernel); |
| 454 |
|
| 455 |
cmDestroyKernelParam->returnValue = cmRet; |
| 456 |
break; |
| 457 |
|
| 458 |
case CM_FN_CMDEVICE_CREATETASK: |
| 459 |
PCM_CREATETASK_PARAM cmCreateTaskParam; |
| 460 |
cmCreateTaskParam = (PCM_CREATETASK_PARAM)(cmPrivateInputData); |
| 461 |
cmRet = device->CreateTask(cmTask); |
| 462 |
|
| 463 |
if(cmRet == CM_SUCCESS && cmTask) |
| 464 |
{ |
| 465 |
cmCreateTaskParam->taskHandle = cmTask; |
| 466 |
CmTaskRT *cmTaskRT = static_cast<CmTaskRT *>(cmTask); |
| 467 |
cmCreateTaskParam->taskIndex = cmTaskRT->GetIndexInTaskArray(); |
| 468 |
} |
| 469 |
cmCreateTaskParam->returnValue = cmRet; |
| 470 |
break; |
| 471 |
|
| 472 |
case CM_FN_CMDEVICE_DESTROYTASK: |
| 473 |
PCM_DESTROYTASK_PARAM cmDestroyTaskParam; |
| 474 |
cmDestroyTaskParam = (PCM_DESTROYTASK_PARAM)(cmPrivateInputData); |
| 475 |
cmTask = (CmTask *)cmDestroyTaskParam->taskHandle; |
| 476 |
|
| 477 |
cmRet = device->DestroyTask(cmTask); |
| 478 |
|
| 479 |
cmDestroyTaskParam->returnValue = cmRet; |
| 480 |
break; |
| 481 |
|
| 482 |
case CM_FN_CMDEVICE_CREATEQUEUE: |
| 483 |
{ |
| 484 |
CM_CREATEQUEUE_PARAM *cmCreateQueParam; |
| 485 |
cmCreateQueParam = (CM_CREATEQUEUE_PARAM *)(cmPrivateInputData); |
| 486 |
|
| 487 |
cmRet = device->CreateQueue(cmQueue); |
| 488 |
|
| 489 |
if (cmRet == CM_SUCCESS && cmQueue != nullptr) |
| 490 |
{ |
| 491 |
// Sync queue option and handle to thin layer. |
| 492 |
CmQueueRT *cmQueueRT = static_cast<CmQueueRT *>(cmQueue); |
| 493 |
cmCreateQueParam->createOption = cmQueueRT->GetQueueOption(); |
| 494 |
cmCreateQueParam->queueHandle = (cmQueue); |
| 495 |
cmCreateQueParam->returnValue = CM_SUCCESS; |
| 496 |
} |
| 497 |
else |
| 498 |
{ |
| 499 |
cmCreateQueParam->queueHandle = nullptr; |
| 500 |
cmCreateQueParam->returnValue = cmRet; |
| 501 |
} |
| 502 |
break; |
| 503 |
} |
| 504 |
|
| 505 |
case CM_FN_CMDEVICE_CREATEQUEUEEX: |
| 506 |
{ |
| 507 |
CM_CREATEQUEUE_PARAM *cmCreateQueParam; |
| 508 |
cmCreateQueParam = (CM_CREATEQUEUE_PARAM *)(cmPrivateInputData); |
| 509 |
CM_ASSERT(cmCreateQueParam); |
| 510 |
|
| 511 |
cmRet = device->CreateQueueEx(cmQueue, cmCreateQueParam->createOption); |
| 512 |
|
| 513 |
cmCreateQueParam->returnValue = cmRet; |
| 514 |
cmCreateQueParam->queueHandle = (cmQueue); |
| 515 |
break; |
| 516 |
} |
| 517 |
|
| 518 |
case CM_FN_CMQUEUE_ENQUEUE: |
| 519 |
{ |
| 520 |
PCM_ENQUEUE_PARAM cmEnqueueParam; |
| 521 |
cmEnqueueParam = (PCM_ENQUEUE_PARAM)(cmPrivateInputData); |
| 522 |
cmQueue = (CmQueue *)cmEnqueueParam->queueHandle; |
| 523 |
cmTask = (CmTask *)cmEnqueueParam->taskHandle; |
| 524 |
cmThreadSpace = (CmThreadSpace *)cmEnqueueParam->threadSpaceHandle; |
| 525 |
cmEvent = (CmEvent*)cmEnqueueParam->eventHandle; // used as input |
| 526 |
|
| 527 |
CM_ASSERT(cmQueue); |
| 528 |
CM_ASSERT(cmTask); |
| 529 |
|
| 530 |
cmRet = cmQueue->Enqueue(cmTask,cmEvent,cmThreadSpace); |
| 531 |
|
| 532 |
cmEnqueueParam->eventHandle = cmEvent; |
| 533 |
cmEnqueueParam->returnValue = cmRet; |
| 534 |
} |
| 535 |
break; |
| 536 |
|
| 537 |
case CM_FN_CMQUEUE_ENQUEUEFAST: |
| 538 |
{ |
| 539 |
PCM_ENQUEUE_PARAM cmEnqueueParam; |
| 540 |
cmEnqueueParam = (PCM_ENQUEUE_PARAM)(cmPrivateInputData); |
| 541 |
cmQueue = (CmQueue *)cmEnqueueParam->queueHandle; |
| 542 |
cmTask = (CmTask *)cmEnqueueParam->taskHandle; |
| 543 |
cmThreadSpace = (CmThreadSpace *)cmEnqueueParam->threadSpaceHandle; |
| 544 |
cmEvent = (CmEvent*)cmEnqueueParam->eventHandle; // used as input |
| 545 |
|
| 546 |
CM_ASSERT(cmQueue); |
| 547 |
CM_ASSERT(cmTask); |
| 548 |
|
| 549 |
cmRet = cmQueue->EnqueueFast(cmTask,cmEvent,cmThreadSpace); |
| 550 |
|
| 551 |
cmEnqueueParam->eventHandle = cmEvent; |
| 552 |
cmEnqueueParam->returnValue = cmRet; |
| 553 |
} |
| 554 |
break; |
| 555 |
|
| 556 |
case CM_FN_CMQUEUE_ENQUEUEWITHHINTS: |
| 557 |
PCM_ENQUEUEHINTS_PARAM cmEnqueueHintsParam; |
| 558 |
cmEnqueueHintsParam = (PCM_ENQUEUEHINTS_PARAM)(cmPrivateInputData); |
| 559 |
cmQueue = (CmQueue *)cmEnqueueHintsParam->queueHandle; |
| 560 |
cmTask = (CmTask *)cmEnqueueHintsParam->taskHandle; |
| 561 |
cmEvent = (CmEvent *)cmEnqueueHintsParam->eventHandle; // used as input |
| 562 |
|
| 563 |
if(cmQueue) |
| 564 |
{ |
| 565 |
cmRet = cmQueue->EnqueueWithHints(cmTask, cmEvent, cmEnqueueHintsParam->hints); |
| 566 |
} |
| 567 |
|
| 568 |
cmEnqueueHintsParam->eventHandle = cmEvent; |
| 569 |
cmEnqueueHintsParam->returnValue = cmRet; |
| 570 |
break; |
| 571 |
|
| 572 |
case CM_FN_CMQUEUE_DESTROYEVENT: |
| 573 |
{ |
| 574 |
PCM_DESTROYEVENT_PARAM cmDestroyEventParam; |
| 575 |
cmDestroyEventParam = (PCM_DESTROYEVENT_PARAM)(cmPrivateInputData); |
| 576 |
cmQueue = (CmQueue *)cmDestroyEventParam->queueHandle; |
| 577 |
cmEvent = (CmEvent *)cmDestroyEventParam->eventHandle; |
| 578 |
CM_ASSERT(cmQueue); |
| 579 |
CM_ASSERT(cmEvent); |
| 580 |
|
| 581 |
cmRet = cmQueue->DestroyEvent(cmEvent); |
| 582 |
|
| 583 |
cmDestroyEventParam->returnValue = cmRet; |
| 584 |
} |
| 585 |
break; |
| 586 |
|
| 587 |
case CM_FN_CMQUEUE_DESTROYEVENTFAST: |
| 588 |
{ |
| 589 |
PCM_DESTROYEVENT_PARAM cmDestroyEventParam; |
| 590 |
cmDestroyEventParam = (PCM_DESTROYEVENT_PARAM)(cmPrivateInputData); |
| 591 |
cmQueue = (CmQueue *)cmDestroyEventParam->queueHandle; |
| 592 |
cmEvent = (CmEvent *)cmDestroyEventParam->eventHandle; |
| 593 |
CM_ASSERT(cmQueue); |
| 594 |
CM_ASSERT(cmEvent); |
| 595 |
|
| 596 |
cmRet = cmQueue->DestroyEventFast(cmEvent); |
| 597 |
|
| 598 |
cmDestroyEventParam->returnValue = cmRet; |
| 599 |
} |
| 600 |
break; |
| 601 |
|
| 602 |
case CM_FN_CMDEVICE_CREATETHREADSPACE: |
| 603 |
PCM_CREATETHREADSPACE_PARAM cmCreateTsParam; |
| 604 |
cmCreateTsParam = (PCM_CREATETHREADSPACE_PARAM)(cmPrivateInputData); |
| 605 |
|
| 606 |
cmRet = device->CreateThreadSpace(cmCreateTsParam->threadSpaceWidth, |
| 607 |
cmCreateTsParam->threadSpaceHeight, |
| 608 |
cmThreadSpace); |
| 609 |
if(cmRet==CM_SUCCESS && cmThreadSpace) |
| 610 |
{ |
| 611 |
cmCreateTsParam->threadSpaceHandle = cmThreadSpace; |
| 612 |
CmThreadSpaceRT *cmThreadSpaceRT = static_cast<CmThreadSpaceRT *>(cmThreadSpace); |
| 613 |
cmCreateTsParam->indexInTSArray = cmThreadSpaceRT->GetIndexInTsArray(); |
| 614 |
} |
| 615 |
cmCreateTsParam->returnValue = cmRet; |
| 616 |
break; |
| 617 |
|
| 618 |
case CM_FN_CMDEVICE_DESTROYTHREADSPACE: |
| 619 |
PCM_DESTROYTHREADSPACE_PARAM cmDestroyTsParam; |
| 620 |
cmDestroyTsParam = (PCM_DESTROYTHREADSPACE_PARAM)(cmPrivateInputData); |
| 621 |
cmThreadSpace = (CmThreadSpace *)cmDestroyTsParam->threadSpaceHandle; |
| 622 |
CM_ASSERT(cmThreadSpace); |
| 623 |
cmRet = device->DestroyThreadSpace(cmThreadSpace); |
| 624 |
cmDestroyTsParam->returnValue = cmRet; |
| 625 |
break; |
| 626 |
|
| 627 |
case CM_FN_CMDEVICE_CREATEVMESURFACEG7_5: |
| 628 |
PCM_CREATEVMESURFACE_PARAM createVmeSurf7p5Param; |
| 629 |
createVmeSurf7p5Param = ( PCM_CREATEVMESURFACE_PARAM )( cmPrivateInputData ); |
| 630 |
|
| 631 |
cmRet = device->CreateVmeSurfaceG7_5((CmSurface2D *) createVmeSurf7p5Param->curSurfHandle, |
| 632 |
(CmSurface2D * *) createVmeSurf7p5Param->forwardSurfArray, |
| 633 |
(CmSurface2D * * )createVmeSurf7p5Param->backwardSurfArray, |
| 634 |
createVmeSurf7p5Param->forwardSurfCount, |
| 635 |
createVmeSurf7p5Param->backwardSurfCount, |
| 636 |
vmeSurIndex); |
| 637 |
|
| 638 |
createVmeSurf7p5Param->vmeSurfIndexHandle = vmeSurIndex; |
| 639 |
createVmeSurf7p5Param->returnValue = cmRet; |
| 640 |
break; |
| 641 |
|
| 642 |
case CM_FN_CMDEVICE_CREATEHEVCVMESURFACEG10: |
| 643 |
PCM_CREATEVMESURFACE_PARAM createVmeSurfParamG10; |
| 644 |
createVmeSurfParamG10 = ( PCM_CREATEVMESURFACE_PARAM )( cmPrivateInputData ); |
| 645 |
|
| 646 |
cmRet = device->CreateHevcVmeSurfaceG10( ( CmSurface2D * )createVmeSurfParamG10->curSurfHandle, |
| 647 |
( CmSurface2D * * )createVmeSurfParamG10->forwardSurfArray, |
| 648 |
( CmSurface2D * * )createVmeSurfParamG10->backwardSurfArray, |
| 649 |
createVmeSurfParamG10->forwardSurfCount, |
| 650 |
createVmeSurfParamG10->backwardSurfCount, |
| 651 |
vmeSurIndex ); |
| 652 |
|
| 653 |
createVmeSurfParamG10->vmeSurfIndexHandle = vmeSurIndex; |
| 654 |
createVmeSurfParamG10->returnValue = cmRet; |
| 655 |
break; |
| 656 |
|
| 657 |
case CM_FN_CMDEVICE_DESTROYVMESURFACE: |
| 658 |
PCM_DESTROYVMESURFACE_PARAM destroyVmeSurfParam; |
| 659 |
destroyVmeSurfParam = ( PCM_DESTROYVMESURFACE_PARAM )( cmPrivateInputData ); |
| 660 |
|
| 661 |
vmeSurIndex = ( SurfaceIndex* )destroyVmeSurfParam->vmeSurfIndexHandle; |
| 662 |
cmRet = deviceRT->DestroyVmeSurface( vmeSurIndex ); |
| 663 |
destroyVmeSurfParam->returnValue = cmRet; |
| 664 |
break; |
| 665 |
|
| 666 |
case CM_FN_CMDEVICE_CONFIGVMESURFACEDIMENSION: |
| 667 |
PCM_CONFIGVMESURFACEDIMENSION_PARAM configSurfStateParam; |
| 668 |
configSurfStateParam = (PCM_CONFIGVMESURFACEDIMENSION_PARAM)(cmPrivateInputData); |
| 669 |
|
| 670 |
vmeSurIndex = (SurfaceIndex* )configSurfStateParam->vmeSurfHandle; |
| 671 |
cmRet = device->SetVmeSurfaceStateParam(vmeSurIndex, configSurfStateParam->surfDimensionPara); |
| 672 |
configSurfStateParam->returnValue = cmRet; |
| 673 |
break; |
| 674 |
|
| 675 |
case CM_FN_CMDEVICE_CREATESAMPLER: |
| 676 |
PCM_CREATESAMPLER_PARAM createSamplerParam; |
| 677 |
createSamplerParam = (PCM_CREATESAMPLER_PARAM)(cmPrivateInputData); |
| 678 |
|
| 679 |
cmRet = device->CreateSampler(createSamplerParam->sampleState, sampler); |
| 680 |
if(cmRet == CM_SUCCESS) |
| 681 |
{ |
| 682 |
cmRet = sampler->GetIndex(samplerIndex); |
| 683 |
createSamplerParam->samplerHandle = static_cast<CmSampler *>(sampler); |
| 684 |
createSamplerParam->samplerIndexHandle = samplerIndex; |
| 685 |
} |
| 686 |
createSamplerParam->returnValue = cmRet; |
| 687 |
break; |
| 688 |
|
| 689 |
case CM_FN_CMDEVICE_CREATESAMPLER_EX: |
| 690 |
PCM_CREATESAMPLER_PARAM_EX createSamplerParamEx; |
| 691 |
createSamplerParamEx = (PCM_CREATESAMPLER_PARAM_EX)(cmPrivateInputData); |
| 692 |
|
| 693 |
cmRet = device->CreateSamplerEx(createSamplerParamEx->sampleState, sampler); |
| 694 |
if(cmRet == CM_SUCCESS) |
| 695 |
{ |
| 696 |
cmRet = sampler->GetIndex(samplerIndex); |
| 697 |
createSamplerParamEx->samplerHandle = static_cast<CmSampler *>(sampler); |
| 698 |
createSamplerParamEx->samplerIndexHandle = samplerIndex; |
| 699 |
} |
| 700 |
createSamplerParamEx->returnValue = cmRet; |
| 701 |
break; |
| 702 |
|
| 703 |
case CM_FN_CMDEVICE_DESTROYSAMPLER: |
| 704 |
PCM_DESTROYSAMPLER_PARAM destroySamplerParam; |
| 705 |
destroySamplerParam = (PCM_DESTROYSAMPLER_PARAM)(cmPrivateInputData); |
| 706 |
|
| 707 |
sampler = (CmSampler *)destroySamplerParam->samplerHandle; |
| 708 |
cmRet = device->DestroySampler(sampler); |
| 709 |
destroySamplerParam->returnValue = cmRet; |
| 710 |
break; |
| 711 |
|
| 712 |
case CM_FN_CMDEVICE_CREATETHREADGROUPSPACE: |
| 713 |
PCM_CREATETGROUPSPACE_PARAM createTGrpSpaceParam; |
| 714 |
createTGrpSpaceParam = (PCM_CREATETGROUPSPACE_PARAM)(cmPrivateInputData); |
| 715 |
|
| 716 |
cmRet = device->CreateThreadGroupSpaceEx( |
| 717 |
createTGrpSpaceParam->thrdSpaceWidth, |
| 718 |
createTGrpSpaceParam->thrdSpaceHeight, |
| 719 |
createTGrpSpaceParam->thrdSpaceDepth, |
| 720 |
createTGrpSpaceParam->grpSpaceWidth, |
| 721 |
createTGrpSpaceParam->grpSpaceHeight, |
| 722 |
createTGrpSpaceParam->grpSpaceDepth, |
| 723 |
threadGrpSpace); |
| 724 |
if(cmRet == CM_SUCCESS && threadGrpSpace) |
| 725 |
{ |
| 726 |
createTGrpSpaceParam->groupSpaceHandle = static_cast<CmThreadGroupSpace *>(threadGrpSpace); |
| 727 |
createTGrpSpaceParam->threadGroupSpaceIndex = threadGrpSpace->GetIndexInTGsArray(); |
| 728 |
} |
| 729 |
createTGrpSpaceParam->returnValue = cmRet; |
| 730 |
break; |
| 731 |
|
| 732 |
case CM_FN_CMDEVICE_DESTROYTHREADGROUPSPACE: |
| 733 |
PCM_DESTROYTGROPUSPACE_PARAM destroyTGrpSpaceParam; |
| 734 |
destroyTGrpSpaceParam = (PCM_DESTROYTGROPUSPACE_PARAM)(cmPrivateInputData); |
| 735 |
|
| 736 |
threadGrpSpace = (CmThreadGroupSpace *)destroyTGrpSpaceParam->groupSpaceHandle; |
| 737 |
cmRet = device->DestroyThreadGroupSpace(threadGrpSpace); |
| 738 |
destroyTGrpSpaceParam->returnValue = cmRet; |
| 739 |
break; |
| 740 |
|
| 741 |
case CM_FN_CMQUEUE_ENQUEUEWITHGROUP: |
| 742 |
{ |
| 743 |
PCM_ENQUEUEGROUP_PARAM enqueueGroupParam; |
| 744 |
enqueueGroupParam = (PCM_ENQUEUEGROUP_PARAM)(cmPrivateInputData); |
| 745 |
cmQueue = (CmQueue *)enqueueGroupParam->queueHandle; |
| 746 |
threadGrpSpace = (CmThreadGroupSpace *)enqueueGroupParam->threadGroupSpaceHandle; |
| 747 |
cmTask = (CmTask *)enqueueGroupParam->taskHandle; |
| 748 |
cmEvent = (CmEvent*)enqueueGroupParam->eventHandle; // used as input |
| 749 |
|
| 750 |
cmRet = cmQueue->EnqueueWithGroup(cmTask, |
| 751 |
cmEvent, |
| 752 |
threadGrpSpace); |
| 753 |
|
| 754 |
enqueueGroupParam->eventHandle = cmEvent; |
| 755 |
enqueueGroupParam->returnValue = cmRet; |
| 756 |
} |
| 757 |
break; |
| 758 |
|
| 759 |
case CM_FN_CMQUEUE_ENQUEUEWITHGROUPFAST: |
| 760 |
{ |
| 761 |
PCM_ENQUEUEGROUP_PARAM enqueueGroupParam; |
| 762 |
enqueueGroupParam = (PCM_ENQUEUEGROUP_PARAM)(cmPrivateInputData); |
| 763 |
cmQueue = (CmQueue *)enqueueGroupParam->queueHandle; |
| 764 |
threadGrpSpace = (CmThreadGroupSpace *)enqueueGroupParam->threadGroupSpaceHandle; |
| 765 |
cmTask = (CmTask *)enqueueGroupParam->taskHandle; |
| 766 |
cmEvent = (CmEvent*)enqueueGroupParam->eventHandle; // used as input |
| 767 |
|
| 768 |
cmRet = cmQueue->EnqueueWithGroupFast(cmTask, |
| 769 |
cmEvent, |
| 770 |
threadGrpSpace); |
| 771 |
|
| 772 |
enqueueGroupParam->eventHandle = cmEvent; |
| 773 |
enqueueGroupParam->returnValue = cmRet; |
| 774 |
} |
| 775 |
break; |
| 776 |
|
| 777 |
case CM_FN_CMDEVICE_GETCAPS: |
| 778 |
PCM_GETCAPS_PARAM getCapParam; |
| 779 |
getCapParam = (PCM_GETCAPS_PARAM)(cmPrivateInputData); |
| 780 |
|
| 781 |
cmRet = device->GetCaps(getCapParam->capName, |
| 782 |
getCapParam->capValueSize, |
| 783 |
getCapParam->capValue); |
| 784 |
|
| 785 |
if( (cmRet == CM_SUCCESS) && getCapParam->capName == CAP_SURFACE2D_FORMATS) |
| 786 |
{ // need to convert to OSAL Format |
| 787 |
cmRet = ConvertToOperatingSystemAbstractionLayerFormat( |
| 788 |
getCapParam->capValue, CM_MAX_SURFACE2D_FORMAT_COUNT); |
| 789 |
} |
| 790 |
|
| 791 |
if( (cmRet == CM_SUCCESS) && getCapParam->capName == CAP_SURFACE3D_FORMATS) |
| 792 |
{ |
| 793 |
cmRet = ConvertToOperatingSystemAbstractionLayerFormat( |
| 794 |
getCapParam->capValue, CM_MAX_SURFACE3D_FORMAT_COUNT); |
| 795 |
} |
| 796 |
getCapParam->returnValue = cmRet; |
| 797 |
break; |
| 798 |
|
| 799 |
case CM_FN_CMDEVICE_SETCAPS: |
| 800 |
PCM_DEVICE_SETCAP_PARAM setCapParam; |
| 801 |
setCapParam = (PCM_DEVICE_SETCAP_PARAM)(cmPrivateInputData); |
| 802 |
cmRet = device->SetCaps(setCapParam->capName, setCapParam->capValueSize, setCapParam->capValue); |
| 803 |
setCapParam->returnValue = cmRet; |
| 804 |
break; |
| 805 |
|
| 806 |
case CM_FN_CMDEVICE_SETSUGGESTEDL3CONFIG: |
| 807 |
PCM_DEVICE_SETSUGGESTEDL3_PARAM setL3IndexParam; |
| 808 |
setL3IndexParam = (PCM_DEVICE_SETSUGGESTEDL3_PARAM)(cmPrivateInputData); |
| 809 |
cmRet = device->SetSuggestedL3Config(setL3IndexParam->l3SuggestConfig); |
| 810 |
setL3IndexParam->returnValue = cmRet; |
| 811 |
break; |
| 812 |
|
| 813 |
case CM_FN_CMQUEUE_ENQUEUECOPY: |
| 814 |
|
| 815 |
CM_ENQUEUE_GPUCOPY_PARAM *enqueueGpuCopyParam; |
| 816 |
enqueueGpuCopyParam = (CM_ENQUEUE_GPUCOPY_PARAM*)(cmPrivateInputData); |
| 817 |
cmQueue = (CmQueue *)enqueueGpuCopyParam->queueHandle; |
| 818 |
cmQueueRT = static_cast<CmQueueRT*>(cmQueue); |
| 819 |
cmSurface2d = CM_SURFACE_2D(enqueueGpuCopyParam->surface2d); |
| 820 |
cmEvent = (CmEvent*)enqueueGpuCopyParam->eventHandle; // used as input |
| 821 |
|
| 822 |
cmRet = cmQueueRT->EnqueueCopyInternal( cmSurface2d, |
| 823 |
(unsigned char *) enqueueGpuCopyParam->sysMem, |
| 824 |
enqueueGpuCopyParam->widthStride, |
| 825 |
enqueueGpuCopyParam->heightStride, |
| 826 |
enqueueGpuCopyParam->copyDir, |
| 827 |
enqueueGpuCopyParam->option, |
| 828 |
cmEvent); |
| 829 |
|
| 830 |
enqueueGpuCopyParam->eventHandle = cmEvent; |
| 831 |
enqueueGpuCopyParam->returnValue = cmRet; |
| 832 |
|
| 833 |
break; |
| 834 |
|
| 835 |
case CM_FN_CMQUEUE_ENQUEUESURF2DINIT: |
| 836 |
PCM_ENQUEUE_2DINIT_PARAM enqueue2DInitParam; |
| 837 |
enqueue2DInitParam = (PCM_ENQUEUE_2DINIT_PARAM)(cmPrivateInputData); |
| 838 |
|
| 839 |
cmQueue = (CmQueue *)enqueue2DInitParam->queueHandle; |
| 840 |
cmSurf2DBase = (CmSurface2D *)(enqueue2DInitParam->surface2d); |
| 841 |
cmEvent = (CmEvent*)enqueue2DInitParam->eventHandle; // used as input |
| 842 |
CM_ASSERT(cmQueue); |
| 843 |
CM_ASSERT(cmSurf2DBase); |
| 844 |
|
| 845 |
cmRet = cmQueue->EnqueueInitSurface2D(cmSurf2DBase, enqueue2DInitParam->initValue, cmEvent); |
| 846 |
|
| 847 |
enqueue2DInitParam->eventHandle = cmEvent; |
| 848 |
enqueue2DInitParam->returnValue = cmRet; |
| 849 |
break; |
| 850 |
|
| 851 |
case CM_FN_CMQUEUE_ENQUEUECOPY_V2V: |
| 852 |
PCM_ENQUEUE_GPUCOPY_V2V_PARAM enqueueCopyV2VParam; |
| 853 |
enqueueCopyV2VParam = (PCM_ENQUEUE_GPUCOPY_V2V_PARAM)(cmPrivateInputData); |
| 854 |
|
| 855 |
cmQueue = (CmQueue *)enqueueCopyV2VParam->queueHandle; |
| 856 |
cmSrcSurface2d = (CmSurface2D *)(enqueueCopyV2VParam->srcSurface2d); |
| 857 |
cmDstSurface2d = (CmSurface2D *)(enqueueCopyV2VParam->dstSurface2d); |
| 858 |
cmEvent = (CmEvent*)enqueueCopyV2VParam->eventHandle; // used as input |
| 859 |
CM_ASSERT(cmQueue); |
| 860 |
CM_ASSERT(cmSrcSurface2d); |
| 861 |
CM_ASSERT(cmDstSurface2d); |
| 862 |
|
| 863 |
cmRet = cmQueue->EnqueueCopyGPUToGPU(cmDstSurface2d, |
| 864 |
cmSrcSurface2d, |
| 865 |
enqueueCopyV2VParam->option, |
| 866 |
cmEvent); |
| 867 |
|
| 868 |
enqueueCopyV2VParam->eventHandle = cmEvent; |
| 869 |
enqueueCopyV2VParam->returnValue = cmRet; |
| 870 |
|
| 871 |
break; |
| 872 |
|
| 873 |
case CM_FN_CMQUEUE_ENQUEUECOPY_L2L: |
| 874 |
PCM_ENQUEUE_GPUCOPY_L2L_PARAM enqueueCopyL2LParam; |
| 875 |
enqueueCopyL2LParam = (PCM_ENQUEUE_GPUCOPY_L2L_PARAM)(cmPrivateInputData); |
| 876 |
|
| 877 |
cmQueue = (CmQueue *)enqueueCopyL2LParam->queueHandle; |
| 878 |
cmEvent = (CmEvent*)enqueueCopyL2LParam->eventHandle; // used as input |
| 879 |
CM_ASSERT(cmQueue); |
| 880 |
|
| 881 |
cmRet = cmQueue->EnqueueCopyCPUToCPU((unsigned char *) enqueueCopyL2LParam->dstSysMem, |
| 882 |
(unsigned char *) enqueueCopyL2LParam->srcSysMem, |
| 883 |
enqueueCopyL2LParam->copySize, |
| 884 |
enqueueCopyL2LParam->option, |
| 885 |
cmEvent); |
| 886 |
|
| 887 |
enqueueCopyL2LParam->eventHandle = cmEvent; |
| 888 |
enqueueCopyL2LParam->returnValue = cmRet; |
| 889 |
|
| 890 |
break; |
| 891 |
|
| 892 |
case CM_FN_CMQUEUE_ENQUEUECOPY_BUFFER: |
| 893 |
PCM_ENQUEUE_COPY_BUFFER_PARAM enqueueCopyBtoCPUParam; |
| 894 |
enqueueCopyBtoCPUParam = (PCM_ENQUEUE_COPY_BUFFER_PARAM)(cmPrivateInputData); |
| 895 |
cmQueue = (CmQueue*)enqueueCopyBtoCPUParam->cmQueueHandle; |
| 896 |
CM_ASSERT(cmQueue); |
| 897 |
cmEvent = (CmEvent*)enqueueCopyBtoCPUParam->cmEventHandle; // used as input |
| 898 |
cmQueueRT = static_cast<CmQueueRT*>(cmQueue); |
| 899 |
|
| 900 |
cmRet = cmQueueRT->EnqueueBufferCopy((CmBuffer*)enqueueCopyBtoCPUParam->buffer, |
| 901 |
enqueueCopyBtoCPUParam->offset, |
| 902 |
(unsigned char*)enqueueCopyBtoCPUParam->sysMem, |
| 903 |
enqueueCopyBtoCPUParam->copySize, |
| 904 |
(CM_GPUCOPY_DIRECTION)enqueueCopyBtoCPUParam->copyDir, |
| 905 |
(CmEvent*)enqueueCopyBtoCPUParam->wait_event, |
| 906 |
cmEvent, |
| 907 |
enqueueCopyBtoCPUParam->option); |
| 908 |
|
| 909 |
enqueueCopyBtoCPUParam->cmEventHandle = cmEvent; |
| 910 |
enqueueCopyBtoCPUParam->returnValue = cmRet; |
| 911 |
break; |
| 912 |
|
| 913 |
case CM_FN_CMQUEUE_ENQUEUEVEBOX: |
| 914 |
PCM_ENQUEUE_VEBOX_PARAM enqueueVeboxParam; |
| 915 |
enqueueVeboxParam = (PCM_ENQUEUE_VEBOX_PARAM)(cmPrivateInputData); |
| 916 |
cmQueue = (CmQueue *)enqueueVeboxParam->queueHandle; |
| 917 |
cmVebox = (CmVebox *)enqueueVeboxParam->veboxHandle; |
| 918 |
cmEvent = (CmEvent *)enqueueVeboxParam->eventHandle; |
| 919 |
|
| 920 |
if (cmQueue) |
| 921 |
{ |
| 922 |
cmRet = cmQueue->EnqueueVebox(cmVebox, cmEvent); |
| 923 |
} |
| 924 |
|
| 925 |
enqueueVeboxParam->eventHandle = cmEvent; |
| 926 |
enqueueVeboxParam->returnValue = cmRet; |
| 927 |
|
| 928 |
break; |
| 929 |
|
| 930 |
case CM_FN_CMDEVICE_DESTROYSURFACE3D: |
| 931 |
PCM_DESTROY_SURFACE3D_PARAM destroySurf3dParam; |
| 932 |
destroySurf3dParam = (PCM_DESTROY_SURFACE3D_PARAM)(cmPrivateInputData); |
| 933 |
cmSurface3d = static_cast<CmSurface3D *>(destroySurf3dParam->surface3DHandle); |
| 934 |
|
| 935 |
cmRet = device->DestroySurface(cmSurface3d); |
| 936 |
|
| 937 |
destroySurf3dParam->returnValue = cmRet; |
| 938 |
break; |
| 939 |
|
| 940 |
case CM_FN_CMDEVICE_CREATESAMPLERSURFACE2D: |
| 941 |
PCM_CREATESAMPLER2D_PARAM createSampler2DParam; |
| 942 |
createSampler2DParam = (PCM_CREATESAMPLER2D_PARAM)(cmPrivateInputData); |
| 943 |
|
| 944 |
cmSurf2DBase = (CmSurface2D *)createSampler2DParam->surface2DHandle; |
| 945 |
|
| 946 |
cmRet = device->CreateSamplerSurface2D(cmSurf2DBase, surfaceIndex); |
| 947 |
|
| 948 |
createSampler2DParam->samplerSurfIndexHandle = surfaceIndex; |
| 949 |
createSampler2DParam->returnValue = cmRet; |
| 950 |
break; |
| 951 |
|
| 952 |
case CM_FN_CMDEVICE_CREATESAMPLERSURFACE2D_EX: |
| 953 |
PCM_CREATESAMPLER2DEX_PARAM createSampler2DExParam; |
| 954 |
createSampler2DExParam = (PCM_CREATESAMPLER2DEX_PARAM)(cmPrivateInputData); |
| 955 |
|
| 956 |
cmSurf2DBase = (CmSurface2D *)createSampler2DExParam->surface2DHandle; |
| 957 |
|
| 958 |
cmRet = device->CreateSamplerSurface2DEx(cmSurf2DBase, surfaceIndex, createSampler2DExParam->flag); |
| 959 |
|
| 960 |
createSampler2DExParam->samplerSurfIndexHandle = surfaceIndex; |
| 961 |
createSampler2DExParam->returnValue = cmRet; |
| 962 |
break; |
| 963 |
|
| 964 |
case CM_FN_CMDEVICE_CREATESAMPLERSURFACE2DUP: |
| 965 |
PCM_CREATESAMPLER2DUP_PARAM createSampler2DUPParam; |
| 966 |
createSampler2DUPParam = (PCM_CREATESAMPLER2DUP_PARAM)(cmPrivateInputData); |
| 967 |
|
| 968 |
cmSurface2dup = (CmSurface2DUP *)createSampler2DUPParam->surface2DUPHandle; |
| 969 |
|
| 970 |
cmRet = device->CreateSamplerSurface2DUP(cmSurface2dup, surfaceIndex); |
| 971 |
|
| 972 |
createSampler2DUPParam->samplerSurfIndexHandle = surfaceIndex; |
| 973 |
createSampler2DUPParam->returnValue = cmRet; |
| 974 |
break; |
| 975 |
|
| 976 |
case CM_FN_CMDEVICE_CREATESAMPLERSURFACE3D: |
| 977 |
PCM_CREATESAMPLER3D_PARAM createSampler3DParam; |
| 978 |
createSampler3DParam = (PCM_CREATESAMPLER3D_PARAM)(cmPrivateInputData); |
| 979 |
|
| 980 |
cmSurface3d = (CmSurface3D *)createSampler3DParam->surface3DHandle; |
| 981 |
|
| 982 |
cmRet = device->CreateSamplerSurface3D(cmSurface3d, surfaceIndex); |
| 983 |
|
| 984 |
createSampler3DParam->samplerSurfIndexHandle = surfaceIndex; |
| 985 |
createSampler3DParam->returnValue = cmRet; |
| 986 |
break; |
| 987 |
|
| 988 |
case CM_FN_CMDEVICE_DESTROYSAMPLERSURFACE: |
| 989 |
PCM_DESTROYSAMPLERSURF_PARAM destroySamplerSurfParam; |
| 990 |
destroySamplerSurfParam = (PCM_DESTROYSAMPLERSURF_PARAM)(cmPrivateInputData); |
| 991 |
|
| 992 |
surfaceIndex = (SurfaceIndex *)destroySamplerSurfParam->samplerSurfIndexHandle; |
| 993 |
cmRet = device->DestroySamplerSurface(surfaceIndex ); |
| 994 |
|
| 995 |
destroySamplerSurfParam->returnValue = cmRet; |
| 996 |
break; |
| 997 |
|
| 998 |
case CM_FN_CMDEVICE_CREATESAMPLER8X8: |
| 999 |
PCM_CREATESAMPLER8x8_PARAM createSampler8x8Param; |
| 1000 |
createSampler8x8Param = (PCM_CREATESAMPLER8x8_PARAM)(cmPrivateInputData); |
| 1001 |
|
| 1002 |
cmRet = device->CreateSampler8x8(createSampler8x8Param->sample8x8Desc , |
| 1003 |
sampler8x8); |
| 1004 |
if(cmRet == CM_SUCCESS) |
| 1005 |
{ |
| 1006 |
cmRet = sampler8x8->GetIndex(samplerIndex); |
| 1007 |
createSampler8x8Param->samplerIndexHandle = samplerIndex; |
| 1008 |
createSampler8x8Param->sampler8x8Handle = static_cast<CmSampler8x8 *>(sampler8x8); |
| 1009 |
} |
| 1010 |
createSampler8x8Param->returnValue = cmRet; |
| 1011 |
break; |
| 1012 |
|
| 1013 |
case CM_FN_CMDEVICE_DESTROYSAMPLER8X8: |
| 1014 |
PCM_DESTROYSAMPLER8x8_PARAM destroySampler8x8Param; |
| 1015 |
destroySampler8x8Param = (PCM_DESTROYSAMPLER8x8_PARAM)(cmPrivateInputData); |
| 1016 |
|
| 1017 |
sampler8x8 = (CmSampler8x8 *)destroySampler8x8Param->sampler8x8Handle; |
| 1018 |
cmRet = device->DestroySampler8x8( sampler8x8); |
| 1019 |
|
| 1020 |
destroySampler8x8Param->returnValue = cmRet; |
| 1021 |
break; |
| 1022 |
|
| 1023 |
case CM_FN_CMDEVICE_CREATESAMPLER8X8SURFACE: |
| 1024 |
PCM_CREATESAMPLER8x8SURF_PARAM createSampler8x8SurfParam; |
| 1025 |
createSampler8x8SurfParam = (PCM_CREATESAMPLER8x8SURF_PARAM)(cmPrivateInputData); |
| 1026 |
|
| 1027 |
cmRet = device->CreateSampler8x8Surface( |
| 1028 |
(CmSurface2D *) createSampler8x8SurfParam->surf2DHandle, |
| 1029 |
surfaceIndex, |
| 1030 |
createSampler8x8SurfParam->sampler8x8Type, |
| 1031 |
createSampler8x8SurfParam->sampler8x8Mode); |
| 1032 |
|
| 1033 |
createSampler8x8SurfParam->surfIndexHandle = surfaceIndex; |
| 1034 |
createSampler8x8SurfParam->returnValue = cmRet; |
| 1035 |
break; |
| 1036 |
|
| 1037 |
case CM_FN_CMDEVICE_CREATESAMPLER8X8SURFACE_EX: |
| 1038 |
PCM_CREATESAMPLER8x8SURFEX_PARAM createSampler8x8SurfParamEx; |
| 1039 |
createSampler8x8SurfParamEx = (PCM_CREATESAMPLER8x8SURFEX_PARAM)(cmPrivateInputData); |
| 1040 |
|
| 1041 |
cmRet = device->CreateSampler8x8SurfaceEx( |
| 1042 |
(CmSurface2D *)createSampler8x8SurfParamEx->surf2DHandle, |
| 1043 |
surfaceIndex, |
| 1044 |
createSampler8x8SurfParamEx->sampler8x8Type, |
| 1045 |
createSampler8x8SurfParamEx->sampler8x8Mode, |
| 1046 |
createSampler8x8SurfParamEx->flag); |
| 1047 |
|
| 1048 |
createSampler8x8SurfParamEx->surfIndexHandle = surfaceIndex; |
| 1049 |
createSampler8x8SurfParamEx->returnValue = cmRet; |
| 1050 |
break; |
| 1051 |
|
| 1052 |
case CM_FN_CMDEVICE_DESTROYSAMPLER8X8SURFACE: |
| 1053 |
PCM_DESTROYSAMPLER8x8SURF_PARAM destroySampler8x8SurfParam; |
| 1054 |
destroySampler8x8SurfParam = (PCM_DESTROYSAMPLER8x8SURF_PARAM)(cmPrivateInputData); |
| 1055 |
|
| 1056 |
cmRet = device->DestroySampler8x8Surface(destroySampler8x8SurfParam->surfIndexHandle); |
| 1057 |
|
| 1058 |
destroySampler8x8SurfParam->returnValue = cmRet; |
| 1059 |
break; |
| 1060 |
|
| 1061 |
#if USE_EXTENSION_CODE |
| 1062 |
case CM_FN_CMDEVICE_ENABLE_GTPIN: |
| 1063 |
hr = CmThinExecuteEnableGTPin(device, cmPrivateInputData); |
| 1064 |
break; |
| 1065 |
|
| 1066 |
case CM_FN_CMDEVICE_REGISTER_GTPIN_MARKERS: |
| 1067 |
hr = CmThinExecuteRegGTPinMarkers(device, cmPrivateInputData); |
| 1068 |
break; |
| 1069 |
#endif |
| 1070 |
|
| 1071 |
case CM_FN_CMDEVICE_INIT_PRINT_BUFFER: |
| 1072 |
PCM_DEVICE_INIT_PRINT_BUFFER_PARAM initPrintBufferParam; |
| 1073 |
initPrintBufferParam = (PCM_DEVICE_INIT_PRINT_BUFFER_PARAM)(cmPrivateInputData); |
| 1074 |
|
| 1075 |
cmRet = device->InitPrintBuffer(initPrintBufferParam->printBufferSize); |
| 1076 |
if( cmRet == CM_SUCCESS) |
| 1077 |
{ |
| 1078 |
//Return the print buffer memory to thin layer |
| 1079 |
deviceRT->GetPrintBufferMem((unsigned char *&)initPrintBufferParam->printBufferMem); |
| 1080 |
} |
| 1081 |
|
| 1082 |
initPrintBufferParam->returnValue = cmRet; |
| 1083 |
break; |
| 1084 |
|
| 1085 |
case CM_FN_CMDEVICE_FLUSH_PRINT_BUFFER: |
| 1086 |
PCM_DEVICE_FLUSH_PRINT_BUFFER_PARAM flushPrintBufferParam; |
| 1087 |
flushPrintBufferParam = (PCM_DEVICE_FLUSH_PRINT_BUFFER_PARAM)(cmPrivateInputData); |
| 1088 |
cmRet = device->FlushPrintBufferIntoFile(flushPrintBufferParam->fileName); |
| 1089 |
flushPrintBufferParam->returnValue = cmRet; |
| 1090 |
break; |
| 1091 |
|
| 1092 |
case CM_FN_CMDEVICE_CREATEVEBOX: |
| 1093 |
{ |
| 1094 |
PCM_CREATEVEBOX_PARAM createVeboxParam; |
| 1095 |
createVeboxParam = (PCM_CREATEVEBOX_PARAM) (cmPrivateInputData); |
| 1096 |
cmRet = device->CreateVebox(cmVebox); |
| 1097 |
if( cmRet == CM_SUCCESS && cmVebox) |
| 1098 |
{ |
| 1099 |
createVeboxParam->veboxHandle = cmVebox; |
| 1100 |
CmVeboxRT *veboxRT = static_cast<CmVeboxRT *>(cmVebox); |
| 1101 |
createVeboxParam->indexInVeboxArray = veboxRT->GetIndexInVeboxArray(); |
| 1102 |
} |
| 1103 |
createVeboxParam->returnValue = cmRet; |
| 1104 |
} |
| 1105 |
break; |
| 1106 |
|
| 1107 |
case CM_FN_CMDEVICE_DESTROYVEBOX: |
| 1108 |
PCM_DESTROYVEBOX_PARAM destroyVeboxParam; |
| 1109 |
destroyVeboxParam = (PCM_DESTROYVEBOX_PARAM)(cmPrivateInputData); |
| 1110 |
cmVebox = (CmVebox *)destroyVeboxParam->veboxHandle; |
| 1111 |
cmRet = device->DestroyVebox(cmVebox); |
| 1112 |
destroyVeboxParam->returnValue = cmRet; |
| 1113 |
break; |
| 1114 |
|
| 1115 |
case CM_FN_CMDEVICE_GETVISAVERSION: |
| 1116 |
CM_GET_VISA_VERSION_PARAM *getVisaVersionParam; |
| 1117 |
getVisaVersionParam = (CM_GET_VISA_VERSION_PARAM *)(cmPrivateInputData); |
| 1118 |
cmRet = device->GetVISAVersion(getVisaVersionParam->majorVersion, getVisaVersionParam->minorVersion); |
| 1119 |
getVisaVersionParam->returnValue = cmRet; |
| 1120 |
break; |
| 1121 |
|
| 1122 |
default: |
| 1123 |
return CM_INVALID_PRIVATE_DATA; |
| 1124 |
|
| 1125 |
} |
| 1126 |
finish: |
| 1127 |
return hr; |
| 1128 |
} |