Path: blob/21.2-virgl/src/intel/vulkan/tests/state_pool.c
4547 views
/*1* Copyright © 2015 Intel Corporation2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*/2223#include <pthread.h>2425#include "anv_private.h"26#include "test_common.h"2728#define NUM_THREADS 829#define STATES_PER_THREAD_LOG2 1030#define STATES_PER_THREAD (1 << STATES_PER_THREAD_LOG2)31#define NUM_RUNS 643233#include "state_pool_test_helper.h"3435int main(void)36{37struct anv_physical_device physical_device = { };38struct anv_device device = {39.physical = &physical_device,40};41struct anv_state_pool state_pool;4243pthread_mutex_init(&device.mutex, NULL);44anv_bo_cache_init(&device.bo_cache);4546for (unsigned i = 0; i < NUM_RUNS; i++) {47anv_state_pool_init(&state_pool, &device, "test", 4096, 0, 256);4849/* Grab one so a zero offset is impossible */50anv_state_pool_alloc(&state_pool, 16, 16);5152run_state_pool_test(&state_pool);5354anv_state_pool_finish(&state_pool);55}5657pthread_mutex_destroy(&device.mutex);58}596061