1// 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
18#include "Device/Color.hpp"
19#include "Device/Config.hpp"
20#include "System/Types.hpp"
21#include "Vulkan/VkFormat.h"
22
23namespace vk
24{
25 class Image;
26}
27
28namespace sw
29{
30 struct Mipmap
31 {
32 const void *buffer;
33
34 short4 uHalf;
35 short4 vHalf;
36 short4 wHalf;
37 int4 width;
38 int4 height;
39 int4 depth;
40 short4 onePitchP;
41 int4 pitchP;
42 int4 sliceP;
43 };
44
45 struct Texture
46 {
47 Mipmap mipmap[MIPMAP_LEVELS];
48
49 float4 widthWidthHeightHeight;
50 float4 width;
51 float4 height;
52 float4 depth;
53 };
54
55 enum 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,
63
64 FILTER_LAST = FILTER_ANISOTROPIC
65 };
66
67 enum MipmapType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
68 {
69 MIPMAP_NONE,
70 MIPMAP_POINT,
71 MIPMAP_LINEAR,
72
73 MIPMAP_LAST = MIPMAP_LINEAR
74 };
75
76 enum AddressingMode ENUM_UNDERLYING_TYPE_UNSIGNED_INT
77 {
78 ADDRESSING_UNUSED,
79 ADDRESSING_WRAP,
80 ADDRESSING_CLAMP,
81 ADDRESSING_MIRROR,
82 ADDRESSING_MIRRORONCE,
83 ADDRESSING_BORDER, // Single color
84 ADDRESSING_SEAMLESS, // Border of pixels
85 ADDRESSING_CUBEFACE, // Cube face layer
86 ADDRESSING_LAYER, // Array layer
87 ADDRESSING_TEXELFETCH,
88
89 ADDRESSING_LAST = ADDRESSING_TEXELFETCH
90 };
91
92 struct Sampler
93 {
94 VkImageViewType textureType;
95 vk::Format textureFormat;
96 FilterType textureFilter;
97 AddressingMode addressingModeU;
98 AddressingMode addressingModeV;
99 AddressingMode addressingModeW;
100 MipmapType mipmapFilter;
101 VkComponentMapping swizzle;
102 int gatherComponent;
103 bool highPrecisionFiltering;
104 bool compareEnable;
105 VkCompareOp compareOp;
106 VkBorderColor border;
107 bool unnormalizedCoordinates;
108 bool largeTexture;
109
110 VkSamplerYcbcrModelConversion ycbcrModel;
111 bool studioSwing; // Narrow range
112 bool swappedChroma; // Cb/Cr components in reverse order
113 };
114}
115
116#endif // sw_Sampler_hpp
117