blob: 9d80a3b813fedfdad255522728ee071c9a242e7c [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
Alexis Hetu696926d2019-03-18 11:30:01 -040018#include "Device/Color.hpp"
Nicolas Capens1d8c8db2018-11-05 16:30:42 -050019#include "Device/Config.hpp"
Nicolas Capens1d8c8db2018-11-05 16:30:42 -050020#include "System/Types.hpp"
Alexis Hetu696926d2019-03-18 11:30:01 -040021#include "Vulkan/VkFormat.h"
22
23namespace vk
24{
25 class Image;
26}
Nicolas Capens68a82382018-10-02 13:16:55 -040027
28namespace sw
29{
30 struct Mipmap
31 {
Nicolas Capensbb575d42019-05-31 15:36:59 -040032 const void *buffer;
Nicolas Capens68a82382018-10-02 13:16:55 -040033
Nicolas Capensfcc64412019-05-16 12:35:21 -040034 short4 uHalf;
35 short4 vHalf;
36 short4 wHalf;
Alexis Hetu710fcd52019-05-24 17:20:21 -040037 int4 width;
38 int4 height;
39 int4 depth;
Nicolas Capensfcc64412019-05-16 12:35:21 -040040 short4 onePitchP;
Nicolas Capens68a82382018-10-02 13:16:55 -040041 int4 pitchP;
42 int4 sliceP;
43 };
44
45 struct Texture
46 {
47 Mipmap mipmap[MIPMAP_LEVELS];
48
Nicolas Capens1e7120e2019-04-30 17:33:26 -040049 float4 widthWidthHeightHeight;
50 float4 width;
51 float4 height;
52 float4 depth;
Nicolas Capens68a82382018-10-02 13:16:55 -040053 };
54
55 enum SamplerType
56 {
57 SAMPLER_PIXEL,
58 SAMPLER_VERTEX
59 };
60
61 enum TextureType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
62 {
Nicolas Capensa47a5162019-04-24 02:41:27 -040063 TEXTURE_NULL, // TODO(b/129523279): Eliminate
64 TEXTURE_1D,
Nicolas Capens68a82382018-10-02 13:16:55 -040065 TEXTURE_2D,
Nicolas Capens68a82382018-10-02 13:16:55 -040066 TEXTURE_3D,
Nicolas Capensa47a5162019-04-24 02:41:27 -040067 TEXTURE_CUBE,
Nicolas Capens8ac0bd62019-06-06 13:03:56 -040068 TEXTURE_1D_ARRAY, // Treated as 2D texture with second coordinate 0. TODO(b/134669567)
Nicolas Capens68a82382018-10-02 13:16:55 -040069 TEXTURE_2D_ARRAY,
Nicolas Capensa47a5162019-04-24 02:41:27 -040070 TEXTURE_CUBE_ARRAY,
Nicolas Capens68a82382018-10-02 13:16:55 -040071
Nicolas Capensa47a5162019-04-24 02:41:27 -040072 TEXTURE_LAST = TEXTURE_CUBE_ARRAY
Nicolas Capens68a82382018-10-02 13:16:55 -040073 };
74
75 enum FilterType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
76 {
77 FILTER_POINT,
78 FILTER_GATHER,
79 FILTER_MIN_POINT_MAG_LINEAR,
80 FILTER_MIN_LINEAR_MAG_POINT,
81 FILTER_LINEAR,
82 FILTER_ANISOTROPIC,
83
84 FILTER_LAST = FILTER_ANISOTROPIC
85 };
86
87 enum MipmapType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
88 {
89 MIPMAP_NONE,
90 MIPMAP_POINT,
91 MIPMAP_LINEAR,
92
93 MIPMAP_LAST = MIPMAP_LINEAR
94 };
95
96 enum AddressingMode ENUM_UNDERLYING_TYPE_UNSIGNED_INT
97 {
Nicolas Capens8da52532019-05-07 14:22:31 -040098 ADDRESSING_UNUSED,
Nicolas Capens68a82382018-10-02 13:16:55 -040099 ADDRESSING_WRAP,
100 ADDRESSING_CLAMP,
101 ADDRESSING_MIRROR,
102 ADDRESSING_MIRRORONCE,
103 ADDRESSING_BORDER, // Single color
104 ADDRESSING_SEAMLESS, // Border of pixels
Nicolas Capensbb575d42019-05-31 15:36:59 -0400105 ADDRESSING_CUBEFACE, // Cube face layer
106 ADDRESSING_LAYER, // Array layer
Nicolas Capens68a82382018-10-02 13:16:55 -0400107 ADDRESSING_TEXELFETCH,
108
109 ADDRESSING_LAST = ADDRESSING_TEXELFETCH
110 };
111
112 enum CompareFunc ENUM_UNDERLYING_TYPE_UNSIGNED_INT
113 {
114 COMPARE_BYPASS,
115 COMPARE_LESSEQUAL,
116 COMPARE_GREATEREQUAL,
117 COMPARE_LESS,
118 COMPARE_GREATER,
119 COMPARE_EQUAL,
120 COMPARE_NOTEQUAL,
121 COMPARE_ALWAYS,
122 COMPARE_NEVER,
123
124 COMPARE_LAST = COMPARE_NEVER
125 };
126
127 enum SwizzleType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
128 {
129 SWIZZLE_RED,
130 SWIZZLE_GREEN,
131 SWIZZLE_BLUE,
132 SWIZZLE_ALPHA,
133 SWIZZLE_ZERO,
134 SWIZZLE_ONE,
135
136 SWIZZLE_LAST = SWIZZLE_ONE
137 };
138
Nicolas Capens1e7120e2019-04-30 17:33:26 -0400139 struct Sampler
Nicolas Capens68a82382018-10-02 13:16:55 -0400140 {
Nicolas Capens68a82382018-10-02 13:16:55 -0400141 TextureType textureType;
Nicolas Capens1e7120e2019-04-30 17:33:26 -0400142 vk::Format textureFormat;
Nicolas Capens68a82382018-10-02 13:16:55 -0400143 FilterType textureFilter;
144 AddressingMode addressingModeU;
145 AddressingMode addressingModeV;
146 AddressingMode addressingModeW;
Nicolas Capens1e7120e2019-04-30 17:33:26 -0400147 MipmapType mipmapFilter;
Chris Forbes3c2035312019-04-25 08:30:58 -0700148 VkComponentMapping swizzle;
Nicolas Capens57253152019-05-10 20:25:17 -0700149 int gatherComponent;
Nicolas Capens1e7120e2019-04-30 17:33:26 -0400150 bool highPrecisionFiltering;
Chris Forbesc71c17f2019-05-04 10:01:04 -0700151 bool compareEnable;
152 VkCompareOp compareOp;
Nicolas Capens1e7120e2019-04-30 17:33:26 -0400153 VkBorderColor border;
Alexis Hetu036cc9a2019-05-16 17:24:22 -0400154 bool unnormalizedCoordinates;
Alexis Hetu710fcd52019-05-24 17:20:21 -0400155 bool largeTexture;
Nicolas Capens68a82382018-10-02 13:16:55 -0400156
Nicolas Capens51e9e562019-05-16 14:01:16 -0400157 VkSamplerYcbcrModelConversion ycbcrModel;
158 bool studioSwing; // Narrow range
159 bool swappedChroma; // Cb/Cr components in reverse order
Nicolas Capens68a82382018-10-02 13:16:55 -0400160 };
161}
162
163#endif // sw_Sampler_hpp