Path: blob/21.2-virgl/src/intel/common/intel_sample_positions.h
4547 views
/*1* Copyright © 2016 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*/22#ifndef INTEL_SAMPLE_POSITIONS_H23#define INTEL_SAMPLE_POSITIONS_H2425#include <util/macros.h>2627/*28* This file defines the standard multisample positions used by both GL and29* Vulkan. These correspond to the Vulkan "standard sample locations".30*/3132struct intel_sample_position {33float x;34float y;35};3637extern const struct intel_sample_position intel_sample_positions_1x[];38extern const struct intel_sample_position intel_sample_positions_2x[];39extern const struct intel_sample_position intel_sample_positions_4x[];40extern const struct intel_sample_position intel_sample_positions_8x[];41extern const struct intel_sample_position intel_sample_positions_16x[];4243static inline const struct intel_sample_position *44intel_get_sample_positions(int samples)45{46switch (samples) {47case 1: return intel_sample_positions_1x;48case 2: return intel_sample_positions_2x;49case 4: return intel_sample_positions_4x;50case 8: return intel_sample_positions_8x;51case 16: return intel_sample_positions_16x;52default: unreachable("Invalid sample count");53}54}5556/* Examples:57* in case of GFX_VER < 8:58* INTEL_SAMPLE_POS_ELEM(ms.Sample, info->pSampleLocations, 0); expands to:59* ms.Sample0XOffset = info->pSampleLocations[0].x;60* ms.Sample0YOffset = info->pSampleLocations[0].y;61*62* in case of GFX_VER >= 8:63* INTEL_SAMPLE_POS_ELEM(sp._16xSample, info->pSampleLocations, 0); expands to:64* sp._16xSample0XOffset = info->pSampleLocations[0].x;65* sp._16xSample0YOffset = info->pSampleLocations[0].y;66*/6768#define INTEL_SAMPLE_POS_ELEM(prefix, arr, sample_idx) \69prefix##sample_idx##XOffset = arr[sample_idx].x; \70prefix##sample_idx##YOffset = arr[sample_idx].y;7172#define INTEL_SAMPLE_POS_1X_ARRAY(prefix, arr)\73INTEL_SAMPLE_POS_ELEM(prefix, arr, 0);7475#define INTEL_SAMPLE_POS_2X_ARRAY(prefix, arr) \76INTEL_SAMPLE_POS_ELEM(prefix, arr, 0); \77INTEL_SAMPLE_POS_ELEM(prefix, arr, 1);7879#define INTEL_SAMPLE_POS_4X_ARRAY(prefix, arr) \80INTEL_SAMPLE_POS_ELEM(prefix, arr, 0); \81INTEL_SAMPLE_POS_ELEM(prefix, arr, 1); \82INTEL_SAMPLE_POS_ELEM(prefix, arr, 2); \83INTEL_SAMPLE_POS_ELEM(prefix, arr, 3);8485#define INTEL_SAMPLE_POS_8X_ARRAY(prefix, arr) \86INTEL_SAMPLE_POS_ELEM(prefix, arr, 0); \87INTEL_SAMPLE_POS_ELEM(prefix, arr, 1); \88INTEL_SAMPLE_POS_ELEM(prefix, arr, 2); \89INTEL_SAMPLE_POS_ELEM(prefix, arr, 3); \90INTEL_SAMPLE_POS_ELEM(prefix, arr, 4); \91INTEL_SAMPLE_POS_ELEM(prefix, arr, 5); \92INTEL_SAMPLE_POS_ELEM(prefix, arr, 6); \93INTEL_SAMPLE_POS_ELEM(prefix, arr, 7);9495#define INTEL_SAMPLE_POS_16X_ARRAY(prefix, arr) \96INTEL_SAMPLE_POS_ELEM(prefix, arr, 0); \97INTEL_SAMPLE_POS_ELEM(prefix, arr, 1); \98INTEL_SAMPLE_POS_ELEM(prefix, arr, 2); \99INTEL_SAMPLE_POS_ELEM(prefix, arr, 3); \100INTEL_SAMPLE_POS_ELEM(prefix, arr, 4); \101INTEL_SAMPLE_POS_ELEM(prefix, arr, 5); \102INTEL_SAMPLE_POS_ELEM(prefix, arr, 6); \103INTEL_SAMPLE_POS_ELEM(prefix, arr, 7); \104INTEL_SAMPLE_POS_ELEM(prefix, arr, 8); \105INTEL_SAMPLE_POS_ELEM(prefix, arr, 9); \106INTEL_SAMPLE_POS_ELEM(prefix, arr, 10); \107INTEL_SAMPLE_POS_ELEM(prefix, arr, 11); \108INTEL_SAMPLE_POS_ELEM(prefix, arr, 12); \109INTEL_SAMPLE_POS_ELEM(prefix, arr, 13); \110INTEL_SAMPLE_POS_ELEM(prefix, arr, 14); \111INTEL_SAMPLE_POS_ELEM(prefix, arr, 15);112113#define INTEL_SAMPLE_POS_1X(prefix) \114INTEL_SAMPLE_POS_1X_ARRAY(prefix, intel_sample_positions_1x)115116#define INTEL_SAMPLE_POS_2X(prefix) \117INTEL_SAMPLE_POS_2X_ARRAY(prefix, intel_sample_positions_2x)118119#define INTEL_SAMPLE_POS_4X(prefix) \120INTEL_SAMPLE_POS_4X_ARRAY(prefix, intel_sample_positions_4x)121122#define INTEL_SAMPLE_POS_8X(prefix) \123INTEL_SAMPLE_POS_8X_ARRAY(prefix, intel_sample_positions_8x)124125#define INTEL_SAMPLE_POS_16X(prefix) \126INTEL_SAMPLE_POS_16X_ARRAY(prefix, intel_sample_positions_16x)127128#endif /* INTEL_SAMPLE_POSITIONS_H */129130131