1 /* 2 * Copyright (C) 2020-2021 Intel Corporation 3 * 4 * SPDX-License-Identifier: MIT 5 * 6 */ 7 8 #include "level_zero/core/source/sampler/sampler_imp.h" 9 10 #include "level_zero/core/source/device/device.h" 11 12 namespace L0 { 13 14 SamplerAllocatorFn samplerFactory[IGFX_MAX_PRODUCT] = {}; 15 destroy()16ze_result_t SamplerImp::destroy() { 17 delete this; 18 return ZE_RESULT_SUCCESS; 19 } 20 initialize(Device * device,const ze_sampler_desc_t * desc)21ze_result_t SamplerImp::initialize(Device *device, const ze_sampler_desc_t *desc) { 22 samplerDesc = *desc; 23 return ZE_RESULT_SUCCESS; 24 } 25 create(uint32_t productFamily,Device * device,const ze_sampler_desc_t * desc)26Sampler *Sampler::create(uint32_t productFamily, Device *device, const ze_sampler_desc_t *desc) { 27 SamplerAllocatorFn allocator = nullptr; 28 if (productFamily < IGFX_MAX_PRODUCT) { 29 allocator = samplerFactory[productFamily]; 30 } 31 32 SamplerImp *sampler = nullptr; 33 if (allocator) { 34 sampler = static_cast<SamplerImp *>((*allocator)()); 35 if (sampler->initialize(device, desc) != ZE_RESULT_SUCCESS) { 36 sampler->destroy(); 37 sampler = nullptr; 38 } 39 } 40 41 return sampler; 42 } 43 44 } // namespace L0 45