1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
#ifndef _TCUTEXTUREUTIL_HPP
#define _TCUTEXTUREUTIL_HPP
/*-------------------------------------------------------------------------
* drawElements Quality Program Tester Core
* ----------------------------------------
*
* Copyright 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*//*!
* \file
* \brief Texture utilities.
*//*--------------------------------------------------------------------*/
#include "tcuDefs.hpp"
#include "tcuTexture.hpp"
namespace tcu
{
// PixelBufferAccess utilities.
PixelBufferAccess getSubregion (const PixelBufferAccess& access, int x, int y, int z, int width, int height, int depth);
ConstPixelBufferAccess getSubregion (const ConstPixelBufferAccess& access, int x, int y, int z, int width, int height, int depth);
PixelBufferAccess getSubregion (const PixelBufferAccess& access, int x, int y, int width, int height);
ConstPixelBufferAccess getSubregion (const ConstPixelBufferAccess& access, int x, int y, int width, int height);
PixelBufferAccess flipYAccess (const PixelBufferAccess& access);
ConstPixelBufferAccess flipYAccess (const ConstPixelBufferAccess& access);
// sRGB - linear conversion.
Vec4 sRGBToLinear (const Vec4& cs);
Vec4 linearToSRGB (const Vec4& cl);
/*--------------------------------------------------------------------*//*!
* \brief Color channel storage type
*//*--------------------------------------------------------------------*/
enum TextureChannelClass
{
TEXTURECHANNELCLASS_SIGNED_FIXED_POINT = 0,
TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT,
TEXTURECHANNELCLASS_SIGNED_INTEGER,
TEXTURECHANNELCLASS_UNSIGNED_INTEGER,
TEXTURECHANNELCLASS_FLOATING_POINT,
TEXTURECHANNELCLASS_LAST
};
TextureChannelClass getTextureChannelClass (TextureFormat::ChannelType channelType);
/*--------------------------------------------------------------------*//*!
* \brief Standard parameters for texture format testing
*//*--------------------------------------------------------------------*/
struct TextureFormatInfo
{
Vec4 valueMin;
Vec4 valueMax;
Vec4 lookupScale;
Vec4 lookupBias;
TextureFormatInfo (const Vec4& valueMin_, const Vec4& valueMax_, const Vec4& lookupScale_, const Vec4& lookupBias_)
: valueMin (valueMin_)
, valueMax (valueMax_)
, lookupScale (lookupScale_)
, lookupBias (lookupBias_)
{
}
};
TextureFormatInfo getTextureFormatInfo (const TextureFormat& format);
IVec4 getTextureFormatBitDepth (const TextureFormat& format);
// Texture fill.
void clear (const PixelBufferAccess& access, const Vec4& color);
void clear (const PixelBufferAccess& access, const IVec4& color);
void clearDepth (const PixelBufferAccess& access, float depth);
void clearStencil (const PixelBufferAccess& access, int stencil);
void fillWithComponentGradients (const PixelBufferAccess& access, const Vec4& minVal, const Vec4& maxVal);
void fillWithGrid (const PixelBufferAccess& access, int cellSize, const Vec4& colorA, const Vec4& colorB);
void fillWithRepeatableGradient (const PixelBufferAccess& access, const Vec4& colorA, const Vec4& colorB);
void fillWithMetaballs (const PixelBufferAccess& access, int numMetaballs, deUint32 seed);
void fillWithRGBAQuads (const PixelBufferAccess& access);
void copy (const PixelBufferAccess& dst, const ConstPixelBufferAccess& src);
void scale (const PixelBufferAccess& dst, const ConstPixelBufferAccess& src, Sampler::FilterMode filter);
void estimatePixelValueRange (const ConstPixelBufferAccess& access, Vec4& minVal, Vec4& maxVal);
void computePixelScaleBias (const ConstPixelBufferAccess& access, Vec4& scale, Vec4& bias);
int getCubeArrayFaceIndex (CubeFace face);
//! FP32->U8 with RTE rounding (extremely fast, always accurate).
inline deUint8 floatToU8 (float fv)
{
union { float fv; deUint32 uv; deInt32 iv; } v;
v.fv = fv;
const deUint32 e = (deUint32)(126-(v.iv>>23));
deUint32 m = v.uv;
m &= 0x00ffffffu;
m |= 0x00800000u;
m = (m << 8) - m;
m = 0x00800000u + (m >> e);
if (e > 8)
m = e;
return (deUint8)(m>>24);
}
} // tcu
#endif // _TCUTEXTUREUTIL_HPP
|