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