blob: e65b2e156fe9e7fbbcdb84934d7887f7c45d061e [file] [log] [blame]
Nicolas Capens68a82382018-10-02 13:16:55 -04001// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef sw_Sampler_hpp
16#define sw_Sampler_hpp
17
Nicolas Capens1d8c8db2018-11-05 16:30:42 -050018#include "Device/Config.hpp"
Nicolas Capens1d8c8db2018-11-05 16:30:42 -050019#include "System/Types.hpp"
Antonio Maiorano42fd1592020-04-27 11:30:40 -040020#include "Vulkan/VkFormat.hpp"
Alexis Hetu696926d2019-03-18 11:30:01 -040021
Ben Claytonfccfc562019-12-17 20:37:31 +000022namespace vk {
23class Image;
24}
Nicolas Capens157ba262019-12-10 17:49:14 -050025
26namespace sw {
27
28struct Mipmap
Alexis Hetu696926d2019-03-18 11:30:01 -040029{
Nicolas Capens157ba262019-12-10 17:49:14 -050030 const void *buffer;
Nicolas Capens68a82382018-10-02 13:16:55 -040031
Nicolas Capens157ba262019-12-10 17:49:14 -050032 short4 uHalf;
33 short4 vHalf;
34 short4 wHalf;
35 int4 width;
36 int4 height;
37 int4 depth;
38 short4 onePitchP;
39 int4 pitchP;
40 int4 sliceP;
41 int4 samplePitchP;
42 int4 sampleMax;
43};
44
45struct Texture
Nicolas Capens68a82382018-10-02 13:16:55 -040046{
Nicolas Capens157ba262019-12-10 17:49:14 -050047 Mipmap mipmap[MIPMAP_LEVELS];
Nicolas Capens68a82382018-10-02 13:16:55 -040048
Nicolas Capens157ba262019-12-10 17:49:14 -050049 float4 widthWidthHeightHeight;
50 float4 width;
51 float4 height;
52 float4 depth;
53};
Nicolas Capens68a82382018-10-02 13:16:55 -040054
Nicolas Capens157ba262019-12-10 17:49:14 -050055enum FilterType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
56{
57 FILTER_POINT,
58 FILTER_GATHER,
59 FILTER_MIN_POINT_MAG_LINEAR,
60 FILTER_MIN_LINEAR_MAG_POINT,
61 FILTER_LINEAR,
62 FILTER_ANISOTROPIC,
Nicolas Capens68a82382018-10-02 13:16:55 -040063
Nicolas Capens157ba262019-12-10 17:49:14 -050064 FILTER_LAST = FILTER_ANISOTROPIC
65};
Nicolas Capens68a82382018-10-02 13:16:55 -040066
Nicolas Capens157ba262019-12-10 17:49:14 -050067enum MipmapType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
68{
69 MIPMAP_NONE,
70 MIPMAP_POINT,
71 MIPMAP_LINEAR,
Nicolas Capens68a82382018-10-02 13:16:55 -040072
Nicolas Capens157ba262019-12-10 17:49:14 -050073 MIPMAP_LAST = MIPMAP_LINEAR
74};
Nicolas Capens68a82382018-10-02 13:16:55 -040075
Nicolas Capens157ba262019-12-10 17:49:14 -050076enum AddressingMode ENUM_UNDERLYING_TYPE_UNSIGNED_INT
77{
78 ADDRESSING_UNUSED,
79 ADDRESSING_WRAP,
80 ADDRESSING_CLAMP,
81 ADDRESSING_MIRROR,
82 ADDRESSING_MIRRORONCE,
Ben Claytonfccfc562019-12-17 20:37:31 +000083 ADDRESSING_BORDER, // Single color
84 ADDRESSING_SEAMLESS, // Border of pixels
85 ADDRESSING_CUBEFACE, // Cube face layer
86 ADDRESSING_LAYER, // Array layer
Nicolas Capens157ba262019-12-10 17:49:14 -050087 ADDRESSING_TEXELFETCH,
Nicolas Capens68a82382018-10-02 13:16:55 -040088
Nicolas Capens157ba262019-12-10 17:49:14 -050089 ADDRESSING_LAST = ADDRESSING_TEXELFETCH
90};
Nicolas Capens68a82382018-10-02 13:16:55 -040091
Nicolas Capens157ba262019-12-10 17:49:14 -050092struct Sampler
93{
94 VkImageViewType textureType;
95 vk::Format textureFormat;
96 FilterType textureFilter;
97 AddressingMode addressingModeU;
98 AddressingMode addressingModeV;
99 AddressingMode addressingModeW;
100 AddressingMode addressingModeY;
101 MipmapType mipmapFilter;
102 VkComponentMapping swizzle;
103 int gatherComponent;
104 bool highPrecisionFiltering;
105 bool compareEnable;
106 VkCompareOp compareOp;
107 VkBorderColor border;
108 bool unnormalizedCoordinates;
Nicolas Capens68a82382018-10-02 13:16:55 -0400109
Nicolas Capens157ba262019-12-10 17:49:14 -0500110 VkSamplerYcbcrModelConversion ycbcrModel;
111 bool studioSwing; // Narrow range
112 bool swappedChroma; // Cb/Cr components in reverse order
Nicolas Capens7f469172020-03-17 17:29:11 -0400113
114 float mipLodBias = 0.0f;
115 float maxAnisotropy = 0.0f;
116 float minLod = 0.0f;
117 float maxLod = 0.0f;
Nicolas Capens157ba262019-12-10 17:49:14 -0500118};
Nicolas Capens68a82382018-10-02 13:16:55 -0400119
Nicolas Capens157ba262019-12-10 17:49:14 -0500120} // namespace sw
Nicolas Capens68a82382018-10-02 13:16:55 -0400121
Ben Claytonfccfc562019-12-17 20:37:31 +0000122#endif // sw_Sampler_hpp