1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2016 Intel Corporation 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21bf215546Sopenharmony_ci * IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci#ifndef INTEL_SAMPLE_POSITIONS_H 24bf215546Sopenharmony_ci#define INTEL_SAMPLE_POSITIONS_H 25bf215546Sopenharmony_ci 26bf215546Sopenharmony_ci#include <util/macros.h> 27bf215546Sopenharmony_ci 28bf215546Sopenharmony_ci/* 29bf215546Sopenharmony_ci * This file defines the standard multisample positions used by both GL and 30bf215546Sopenharmony_ci * Vulkan. These correspond to the Vulkan "standard sample locations". 31bf215546Sopenharmony_ci */ 32bf215546Sopenharmony_ci 33bf215546Sopenharmony_cistruct intel_sample_position { 34bf215546Sopenharmony_ci float x; 35bf215546Sopenharmony_ci float y; 36bf215546Sopenharmony_ci}; 37bf215546Sopenharmony_ci 38bf215546Sopenharmony_ciextern const struct intel_sample_position intel_sample_positions_1x[]; 39bf215546Sopenharmony_ciextern const struct intel_sample_position intel_sample_positions_2x[]; 40bf215546Sopenharmony_ciextern const struct intel_sample_position intel_sample_positions_4x[]; 41bf215546Sopenharmony_ciextern const struct intel_sample_position intel_sample_positions_8x[]; 42bf215546Sopenharmony_ciextern const struct intel_sample_position intel_sample_positions_16x[]; 43bf215546Sopenharmony_ci 44bf215546Sopenharmony_cistatic inline const struct intel_sample_position * 45bf215546Sopenharmony_ciintel_get_sample_positions(int samples) 46bf215546Sopenharmony_ci{ 47bf215546Sopenharmony_ci switch (samples) { 48bf215546Sopenharmony_ci case 1: return intel_sample_positions_1x; 49bf215546Sopenharmony_ci case 2: return intel_sample_positions_2x; 50bf215546Sopenharmony_ci case 4: return intel_sample_positions_4x; 51bf215546Sopenharmony_ci case 8: return intel_sample_positions_8x; 52bf215546Sopenharmony_ci case 16: return intel_sample_positions_16x; 53bf215546Sopenharmony_ci default: unreachable("Invalid sample count"); 54bf215546Sopenharmony_ci } 55bf215546Sopenharmony_ci} 56bf215546Sopenharmony_ci 57bf215546Sopenharmony_ci/* Examples: 58bf215546Sopenharmony_ci * in case of GFX_VER < 8: 59bf215546Sopenharmony_ci * INTEL_SAMPLE_POS_ELEM(ms.Sample, info->pSampleLocations, 0); expands to: 60bf215546Sopenharmony_ci * ms.Sample0XOffset = info->pSampleLocations[0].x; 61bf215546Sopenharmony_ci * ms.Sample0YOffset = info->pSampleLocations[0].y; 62bf215546Sopenharmony_ci * 63bf215546Sopenharmony_ci * in case of GFX_VER >= 8: 64bf215546Sopenharmony_ci * INTEL_SAMPLE_POS_ELEM(sp._16xSample, info->pSampleLocations, 0); expands to: 65bf215546Sopenharmony_ci * sp._16xSample0XOffset = info->pSampleLocations[0].x; 66bf215546Sopenharmony_ci * sp._16xSample0YOffset = info->pSampleLocations[0].y; 67bf215546Sopenharmony_ci */ 68bf215546Sopenharmony_ci 69bf215546Sopenharmony_ci#define INTEL_SAMPLE_POS_ELEM(prefix, arr, sample_idx) \ 70bf215546Sopenharmony_ciprefix##sample_idx##XOffset = arr[sample_idx].x; \ 71bf215546Sopenharmony_ciprefix##sample_idx##YOffset = arr[sample_idx].y; 72bf215546Sopenharmony_ci 73bf215546Sopenharmony_ci#define INTEL_SAMPLE_POS_1X_ARRAY(prefix, arr)\ 74bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 0); 75bf215546Sopenharmony_ci 76bf215546Sopenharmony_ci#define INTEL_SAMPLE_POS_2X_ARRAY(prefix, arr) \ 77bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 0); \ 78bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 1); 79bf215546Sopenharmony_ci 80bf215546Sopenharmony_ci#define INTEL_SAMPLE_POS_4X_ARRAY(prefix, arr) \ 81bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 0); \ 82bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 1); \ 83bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 2); \ 84bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 3); 85bf215546Sopenharmony_ci 86bf215546Sopenharmony_ci#define INTEL_SAMPLE_POS_8X_ARRAY(prefix, arr) \ 87bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 0); \ 88bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 1); \ 89bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 2); \ 90bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 3); \ 91bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 4); \ 92bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 5); \ 93bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 6); \ 94bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 7); 95bf215546Sopenharmony_ci 96bf215546Sopenharmony_ci#define INTEL_SAMPLE_POS_16X_ARRAY(prefix, arr) \ 97bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 0); \ 98bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 1); \ 99bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 2); \ 100bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 3); \ 101bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 4); \ 102bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 5); \ 103bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 6); \ 104bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 7); \ 105bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 8); \ 106bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 9); \ 107bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 10); \ 108bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 11); \ 109bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 12); \ 110bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 13); \ 111bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 14); \ 112bf215546Sopenharmony_ci INTEL_SAMPLE_POS_ELEM(prefix, arr, 15); 113bf215546Sopenharmony_ci 114bf215546Sopenharmony_ci#define INTEL_SAMPLE_POS_1X(prefix) \ 115bf215546Sopenharmony_ci INTEL_SAMPLE_POS_1X_ARRAY(prefix, intel_sample_positions_1x) 116bf215546Sopenharmony_ci 117bf215546Sopenharmony_ci#define INTEL_SAMPLE_POS_2X(prefix) \ 118bf215546Sopenharmony_ci INTEL_SAMPLE_POS_2X_ARRAY(prefix, intel_sample_positions_2x) 119bf215546Sopenharmony_ci 120bf215546Sopenharmony_ci#define INTEL_SAMPLE_POS_4X(prefix) \ 121bf215546Sopenharmony_ci INTEL_SAMPLE_POS_4X_ARRAY(prefix, intel_sample_positions_4x) 122bf215546Sopenharmony_ci 123bf215546Sopenharmony_ci#define INTEL_SAMPLE_POS_8X(prefix) \ 124bf215546Sopenharmony_ci INTEL_SAMPLE_POS_8X_ARRAY(prefix, intel_sample_positions_8x) 125bf215546Sopenharmony_ci 126bf215546Sopenharmony_ci#define INTEL_SAMPLE_POS_16X(prefix) \ 127bf215546Sopenharmony_ci INTEL_SAMPLE_POS_16X_ARRAY(prefix, intel_sample_positions_16x) 128bf215546Sopenharmony_ci 129bf215546Sopenharmony_ci#endif /* INTEL_SAMPLE_POSITIONS_H */ 130