blob: 8768a19631fd2afcee51bddd6890d8ad2d88251f [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 {
32 const void *buffer[6];
33
34 float4 fWidth;
35 float4 fHeight;
36 float4 fDepth;
37
38 short uHalf[4];
39 short vHalf[4];
40 short wHalf[4];
41 short width[4];
42 short height[4];
43 short depth[4];
44 short onePitchP[4];
45 int4 pitchP;
46 int4 sliceP;
47 };
48
49 struct Texture
50 {
51 Mipmap mipmap[MIPMAP_LEVELS];
52
Nicolas Capens1e7120e2019-04-30 17:33:26 -040053 float4 widthWidthHeightHeight;
54 float4 width;
55 float4 height;
56 float4 depth;
Nicolas Capens68a82382018-10-02 13:16:55 -040057 };
58
59 enum SamplerType
60 {
61 SAMPLER_PIXEL,
62 SAMPLER_VERTEX
63 };
64
65 enum TextureType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
66 {
Nicolas Capensa47a5162019-04-24 02:41:27 -040067 TEXTURE_NULL, // TODO(b/129523279): Eliminate
68 TEXTURE_1D,
Nicolas Capens68a82382018-10-02 13:16:55 -040069 TEXTURE_2D,
Nicolas Capens68a82382018-10-02 13:16:55 -040070 TEXTURE_3D,
Nicolas Capensa47a5162019-04-24 02:41:27 -040071 TEXTURE_CUBE,
Nicolas Capense2535df2019-05-06 10:37:50 -040072 TEXTURE_1D_ARRAY, // Treated as 2D texture with second coordinate 0.
Nicolas Capens68a82382018-10-02 13:16:55 -040073 TEXTURE_2D_ARRAY,
Nicolas Capensa47a5162019-04-24 02:41:27 -040074 TEXTURE_CUBE_ARRAY,
Nicolas Capens68a82382018-10-02 13:16:55 -040075
Nicolas Capensa47a5162019-04-24 02:41:27 -040076 TEXTURE_LAST = TEXTURE_CUBE_ARRAY
Nicolas Capens68a82382018-10-02 13:16:55 -040077 };
78
79 enum FilterType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
80 {
81 FILTER_POINT,
82 FILTER_GATHER,
83 FILTER_MIN_POINT_MAG_LINEAR,
84 FILTER_MIN_LINEAR_MAG_POINT,
85 FILTER_LINEAR,
86 FILTER_ANISOTROPIC,
87
88 FILTER_LAST = FILTER_ANISOTROPIC
89 };
90
91 enum MipmapType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
92 {
93 MIPMAP_NONE,
94 MIPMAP_POINT,
95 MIPMAP_LINEAR,
96
97 MIPMAP_LAST = MIPMAP_LINEAR
98 };
99
100 enum AddressingMode ENUM_UNDERLYING_TYPE_UNSIGNED_INT
101 {
Nicolas Capens8da52532019-05-07 14:22:31 -0400102 ADDRESSING_UNUSED,
Nicolas Capens68a82382018-10-02 13:16:55 -0400103 ADDRESSING_WRAP,
104 ADDRESSING_CLAMP,
105 ADDRESSING_MIRROR,
106 ADDRESSING_MIRRORONCE,
107 ADDRESSING_BORDER, // Single color
108 ADDRESSING_SEAMLESS, // Border of pixels
109 ADDRESSING_LAYER,
110 ADDRESSING_TEXELFETCH,
111
112 ADDRESSING_LAST = ADDRESSING_TEXELFETCH
113 };
114
115 enum CompareFunc ENUM_UNDERLYING_TYPE_UNSIGNED_INT
116 {
117 COMPARE_BYPASS,
118 COMPARE_LESSEQUAL,
119 COMPARE_GREATEREQUAL,
120 COMPARE_LESS,
121 COMPARE_GREATER,
122 COMPARE_EQUAL,
123 COMPARE_NOTEQUAL,
124 COMPARE_ALWAYS,
125 COMPARE_NEVER,
126
127 COMPARE_LAST = COMPARE_NEVER
128 };
129
130 enum SwizzleType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
131 {
132 SWIZZLE_RED,
133 SWIZZLE_GREEN,
134 SWIZZLE_BLUE,
135 SWIZZLE_ALPHA,
136 SWIZZLE_ZERO,
137 SWIZZLE_ONE,
138
139 SWIZZLE_LAST = SWIZZLE_ONE
140 };
141
Nicolas Capens1e7120e2019-04-30 17:33:26 -0400142 struct Sampler
Nicolas Capens68a82382018-10-02 13:16:55 -0400143 {
Nicolas Capens68a82382018-10-02 13:16:55 -0400144 TextureType textureType;
Nicolas Capens1e7120e2019-04-30 17:33:26 -0400145 vk::Format textureFormat;
Nicolas Capens68a82382018-10-02 13:16:55 -0400146 FilterType textureFilter;
147 AddressingMode addressingModeU;
148 AddressingMode addressingModeV;
149 AddressingMode addressingModeW;
Nicolas Capens1e7120e2019-04-30 17:33:26 -0400150 MipmapType mipmapFilter;
Chris Forbes3c2035312019-04-25 08:30:58 -0700151 VkComponentMapping swizzle;
Nicolas Capens1e7120e2019-04-30 17:33:26 -0400152 bool highPrecisionFiltering;
Chris Forbesc71c17f2019-05-04 10:01:04 -0700153 bool compareEnable;
154 VkCompareOp compareOp;
Nicolas Capens1e7120e2019-04-30 17:33:26 -0400155 VkBorderColor border;
Alexis Hetu036cc9a2019-05-16 17:24:22 -0400156 bool unnormalizedCoordinates;
Nicolas Capens68a82382018-10-02 13:16:55 -0400157
Nicolas Capens1e7120e2019-04-30 17:33:26 -0400158 #if PERF_PROFILE
159 bool compressedFormat;
160 #endif
Nicolas Capens68a82382018-10-02 13:16:55 -0400161 };
162}
163
164#endif // sw_Sampler_hpp