blob: 48ca936eaea74050140b6efb7478615330228962 [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
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 Capense2535df2019-05-06 10:37:50 -040068 TEXTURE_1D_ARRAY, // Treated as 2D texture with second coordinate 0.
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
105 ADDRESSING_LAYER,
106 ADDRESSING_TEXELFETCH,
107
108 ADDRESSING_LAST = ADDRESSING_TEXELFETCH
109 };
110
111 enum CompareFunc ENUM_UNDERLYING_TYPE_UNSIGNED_INT
112 {
113 COMPARE_BYPASS,
114 COMPARE_LESSEQUAL,
115 COMPARE_GREATEREQUAL,
116 COMPARE_LESS,
117 COMPARE_GREATER,
118 COMPARE_EQUAL,
119 COMPARE_NOTEQUAL,
120 COMPARE_ALWAYS,
121 COMPARE_NEVER,
122
123 COMPARE_LAST = COMPARE_NEVER
124 };
125
126 enum SwizzleType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
127 {
128 SWIZZLE_RED,
129 SWIZZLE_GREEN,
130 SWIZZLE_BLUE,
131 SWIZZLE_ALPHA,
132 SWIZZLE_ZERO,
133 SWIZZLE_ONE,
134
135 SWIZZLE_LAST = SWIZZLE_ONE
136 };
137
Nicolas Capens1e7120e2019-04-30 17:33:26 -0400138 struct Sampler
Nicolas Capens68a82382018-10-02 13:16:55 -0400139 {
Nicolas Capens68a82382018-10-02 13:16:55 -0400140 TextureType textureType;
Nicolas Capens1e7120e2019-04-30 17:33:26 -0400141 vk::Format textureFormat;
Nicolas Capens68a82382018-10-02 13:16:55 -0400142 FilterType textureFilter;
143 AddressingMode addressingModeU;
144 AddressingMode addressingModeV;
145 AddressingMode addressingModeW;
Nicolas Capens1e7120e2019-04-30 17:33:26 -0400146 MipmapType mipmapFilter;
Chris Forbes3c2035312019-04-25 08:30:58 -0700147 VkComponentMapping swizzle;
Nicolas Capens57253152019-05-10 20:25:17 -0700148 int gatherComponent;
Nicolas Capens1e7120e2019-04-30 17:33:26 -0400149 bool highPrecisionFiltering;
Chris Forbesc71c17f2019-05-04 10:01:04 -0700150 bool compareEnable;
151 VkCompareOp compareOp;
Nicolas Capens1e7120e2019-04-30 17:33:26 -0400152 VkBorderColor border;
Alexis Hetu036cc9a2019-05-16 17:24:22 -0400153 bool unnormalizedCoordinates;
Alexis Hetu710fcd52019-05-24 17:20:21 -0400154 bool largeTexture;
Nicolas Capens68a82382018-10-02 13:16:55 -0400155
Nicolas Capens1e7120e2019-04-30 17:33:26 -0400156 #if PERF_PROFILE
157 bool compressedFormat;
158 #endif
Nicolas Capens68a82382018-10-02 13:16:55 -0400159 };
160}
161
162#endif // sw_Sampler_hpp