1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
/*
* Copyright (c) 2017, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
//!
//! \file cm_surface_sampler8x8.cpp
//! \brief Contains Class CmSurfaceSampler8x8 definitions
//!
#include "cm_surface_sampler8x8.h"
#include "cm_debug.h"
#include "cm_surface_manager.h"
#include "cm_device_rt.h"
#include "cm_hal.h"
namespace CMRT_UMD
{
//*-----------------------------------------------------------------------------
//| Purpose: Create CmSurfaceSampler8x8
//| Returns: Result of the operation.
//*-----------------------------------------------------------------------------
int32_t CmSurfaceSampler8x8::Create(
uint32_t index,
uint32_t indexFor2D, //indexing resource array of HalCm
uint32_t cmIndex, //SurfaceIndex's ID for 2D, also indexing surface array in cmrt@umd
CmSurfaceManager* surfaceManager,
CmSurfaceSampler8x8* &surface,
CM_SAMPLER8x8_SURFACE sampler8x8Type,
CM_SURFACE_ADDRESS_CONTROL_MODE mode,
CM_FLAG* flag)
{
int32_t result = CM_SUCCESS;
surface = new ( std::nothrow ) CmSurfaceSampler8x8( cmIndex, indexFor2D, surfaceManager, sampler8x8Type, mode, flag);
if ( surface )
{
result = surface->Initialize( index );
if( result != CM_SUCCESS )
{
CmSurface* baseSurface = surface;
CmSurface::Destroy( baseSurface );
}
}
else
{
CM_ASSERTMESSAGE("Error: Failed to create CmSurfaceSampler8x8 due to out of system memory.");
result = CM_OUT_OF_HOST_MEMORY;
}
return result;
}
// Constructor of CmSurfaceSampler8x8
CmSurfaceSampler8x8::CmSurfaceSampler8x8(
uint32_t cmIndex, //SurfaceIndex's ID for 2D, also indexing surface array in cmrt@umd
uint32_t indexFor2D,
CmSurfaceManager* surfaceManager,
CM_SAMPLER8x8_SURFACE sampler8x8Type,
CM_SURFACE_ADDRESS_CONTROL_MODE mode,
CM_FLAG* flag) :
CmSurface(surfaceManager, false ),
m_indexFor2D( indexFor2D ),
m_surfaceIndex(cmIndex),
m_sampler8x8Type( sampler8x8Type ),
m_nAddressMode( mode )
{
if (flag != nullptr)
{
m_flag.rotationFlag = flag->rotationFlag;
m_flag.chromaSiting = flag->chromaSiting;
}
}
// Destructor of CmSurfaceSampler8x8
CmSurfaceSampler8x8::~CmSurfaceSampler8x8( void )
{
}
//*-----------------------------------------------------------------------------
//| Purpose: Initialize CmSurfaceSampler8x8
//| Returns: Result of the operation.
//*-----------------------------------------------------------------------------
int32_t CmSurfaceSampler8x8::Initialize( uint32_t index )
{
CmSurfaceManager* surfMgr = m_surfaceMgr;
surfMgr->UpdateSurface2DTableRotation(m_indexFor2D, m_flag.rotationFlag);
surfMgr->UpdateSurface2DTableChromaSiting(m_indexFor2D, m_flag.chromaSiting);
return CmSurface::Initialize( index );
}
//*-----------------------------------------------------------------------------
//| Purpose: Get the index of CmSurfaceSampler8x8
//| Returns: Result of the operation.
//*-----------------------------------------------------------------------------
int32_t CmSurfaceSampler8x8::GetIndex( SurfaceIndex*& index )
{
index = m_index;
return CM_SUCCESS;
}
//*-----------------------------------------------------------------------------
//| Purpose: Get the current index of CmSurfaceSampler8x8
//| Returns: Result of the operation.
//*-----------------------------------------------------------------------------
int32_t CmSurfaceSampler8x8::GetIndexCurrent( uint32_t& index )
{
index = m_indexFor2D;
return CM_SUCCESS;
}
int32_t CmSurfaceSampler8x8::GetCmIndex( uint16_t& index )
{
index = (uint16_t)m_surfaceIndex;
return CM_SUCCESS;
}
CM_SAMPLER8x8_SURFACE CmSurfaceSampler8x8::GetSampler8x8SurfaceType()
{
return m_sampler8x8Type;
}
CM_SURFACE_ADDRESS_CONTROL_MODE CmSurfaceSampler8x8::GetAddressControlMode()
{
return m_nAddressMode;
}
int32_t CmSurfaceSampler8x8::SetMemoryObjectControl(MEMORY_OBJECT_CONTROL memCtrl, MEMORY_TYPE memType, uint32_t age)
{
CM_RETURN_CODE hr = CM_SUCCESS;
uint16_t mocs = 0;
CmSurface::SetMemoryObjectControl( memCtrl, memType, age );
CmDeviceRT *cmDevice = nullptr;
m_surfaceMgr->GetCmDevice(cmDevice);
CM_CHK_NULL_RETURN_CMERROR(cmDevice);
PCM_CONTEXT_DATA cmData = (PCM_CONTEXT_DATA)cmDevice->GetAccelData();
CM_CHK_NULL_RETURN_CMERROR(cmData);
CM_CHK_NULL_RETURN_CMERROR(cmData->cmHalState);
mocs = (m_memObjCtrl.mem_ctrl << 8) | (m_memObjCtrl.mem_type<<4) | m_memObjCtrl.age;
CM_ARG_KIND argType;
if (m_sampler8x8Type == CM_VA_SURFACE)
{
argType = ARG_KIND_SURFACE_SAMPLER8X8_VA;
}
else
{
argType = ARG_KIND_SURFACE_SAMPLER8X8_AVS;
}
CM_CHK_MOSSTATUS_GOTOFINISH_CMERROR(cmData->cmHalState->pfnSetSurfaceMOCS(cmData->cmHalState, m_indexFor2D, mocs, argType));
finish:
return hr;
}
}
|