mirror of
https://github.com/godotengine/godot-angle-static.git
synced 2026-01-03 14:09:33 +03:00
Vulkan: Adjust border color
Some border color tests used to fail due to either unclamped color values or not accounting for depth, stencil or luma formats. We now adjust the border color value according to the sampler's format. Test: dEQP-GLES31.functional.texture.border_clamp.* Bug: angleproject:3577 Bug: angleproject:6213 Change-Id: Ib38ce2374622bfafde69fe3fa2d7227d60043954 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3551895 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
committed by
Angle LUCI CQ
parent
f5d20de8c8
commit
3bdbfbf868
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"src/libANGLE/renderer/angle_format.py":
|
||||
"2f8fa768088e22b0963bbdf842d3e725",
|
||||
"src/libANGLE/renderer/gen_load_texture_border_functions_table.py":
|
||||
"77210fd59d00504369691ce2107c1598",
|
||||
"src/libANGLE/renderer/load_texture_border_functions_data.json":
|
||||
"b0616ff2d0038bcf910e5691334804bf",
|
||||
"src/libANGLE/renderer/load_texture_border_functions_table_autogen.cpp":
|
||||
"3b54eb135e8f95614a2c715bf9fe572b"
|
||||
}
|
||||
@@ -84,8 +84,6 @@ generators = {
|
||||
'src/libANGLE/renderer/gen_angle_format_table.py',
|
||||
'ANGLE load functions table':
|
||||
'src/libANGLE/renderer/gen_load_functions_table.py',
|
||||
'ANGLE load texture border functions table':
|
||||
'src/libANGLE/renderer/gen_load_texture_border_functions_table.py',
|
||||
'ANGLE shader preprocessor':
|
||||
'src/compiler/preprocessor/generate_parser.py',
|
||||
'ANGLE shader translator':
|
||||
|
||||
@@ -119,6 +119,38 @@ inline T clamp(T x, MIN min, MAX max)
|
||||
return x > min ? (x > max ? max : x) : min;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T clampForBitCount(T value, size_t bitCount)
|
||||
{
|
||||
static_assert(std::numeric_limits<T>::is_integer, "T must be an integer.");
|
||||
|
||||
if (bitCount == 0)
|
||||
{
|
||||
constexpr T kZero = 0;
|
||||
return kZero;
|
||||
}
|
||||
ASSERT(bitCount <= sizeof(T) * 8);
|
||||
|
||||
constexpr bool kIsSigned = std::numeric_limits<T>::is_signed;
|
||||
ASSERT((bitCount > 1) || !kIsSigned);
|
||||
|
||||
T min = 0;
|
||||
T max = 0;
|
||||
if (bitCount == sizeof(T) * 8)
|
||||
{
|
||||
min = std::numeric_limits<T>::min();
|
||||
max = std::numeric_limits<T>::max();
|
||||
}
|
||||
else
|
||||
{
|
||||
constexpr T kOne = 1;
|
||||
min = (kIsSigned) ? -1 * (kOne << (bitCount - 1)) : 0;
|
||||
max = (kIsSigned) ? (kOne << (bitCount - 1)) - 1 : (kOne << bitCount) - 1;
|
||||
}
|
||||
|
||||
return gl::clamp(value, min, max);
|
||||
}
|
||||
|
||||
inline float clamp01(float x)
|
||||
{
|
||||
return clamp(x, 0.0f, 1.0f);
|
||||
|
||||
@@ -364,6 +364,61 @@ TEST(MathUtilTest, RangeIteration)
|
||||
EXPECT_EQ(range.length(), expected);
|
||||
}
|
||||
|
||||
// Tests for clampForBitCount
|
||||
TEST(MathUtilTest, ClampForBitCount)
|
||||
{
|
||||
constexpr uint64_t kUnsignedMax = std::numeric_limits<uint64_t>::max();
|
||||
constexpr int64_t kSignedMax = std::numeric_limits<int64_t>::max();
|
||||
constexpr int64_t kSignedMin = std::numeric_limits<int64_t>::min();
|
||||
constexpr int64_t kRandomValue = 0x4D34A0B1;
|
||||
|
||||
ASSERT_EQ(clampForBitCount<uint64_t>(kUnsignedMax, 64), std::numeric_limits<uint64_t>::max());
|
||||
ASSERT_EQ(clampForBitCount<uint64_t>(kUnsignedMax, 32),
|
||||
static_cast<uint64_t>(std::numeric_limits<uint32_t>::max()));
|
||||
ASSERT_EQ(clampForBitCount<uint64_t>(kUnsignedMax, 16),
|
||||
static_cast<uint64_t>(std::numeric_limits<uint16_t>::max()));
|
||||
ASSERT_EQ(clampForBitCount<uint64_t>(kUnsignedMax, 8),
|
||||
static_cast<uint64_t>(std::numeric_limits<uint8_t>::max()));
|
||||
ASSERT_EQ(clampForBitCount<uint64_t>(kUnsignedMax, 4), 15u);
|
||||
ASSERT_EQ(clampForBitCount<uint64_t>(kUnsignedMax, 2), 3u);
|
||||
ASSERT_EQ(clampForBitCount<uint64_t>(kUnsignedMax, 1), 1u);
|
||||
ASSERT_EQ(clampForBitCount<uint64_t>(kUnsignedMax, 0), 0u);
|
||||
|
||||
ASSERT_EQ(clampForBitCount<int64_t>(kSignedMax, 64), std::numeric_limits<int64_t>::max());
|
||||
ASSERT_EQ(clampForBitCount<uint64_t>(static_cast<uint64_t>(kSignedMax), 64),
|
||||
static_cast<uint64_t>(std::numeric_limits<int64_t>::max()));
|
||||
ASSERT_EQ(clampForBitCount<int64_t>(kSignedMax, 32),
|
||||
static_cast<int64_t>(std::numeric_limits<int32_t>::max()));
|
||||
ASSERT_EQ(clampForBitCount<int64_t>(kSignedMax, 16),
|
||||
static_cast<int64_t>(std::numeric_limits<int16_t>::max()));
|
||||
ASSERT_EQ(clampForBitCount<int64_t>(kSignedMax, 8),
|
||||
static_cast<int64_t>(std::numeric_limits<int8_t>::max()));
|
||||
ASSERT_EQ(clampForBitCount<int64_t>(kSignedMax, 4), 7);
|
||||
ASSERT_EQ(clampForBitCount<int64_t>(kSignedMax, 2), 1);
|
||||
ASSERT_EQ(clampForBitCount<int64_t>(kSignedMax, 0), 0);
|
||||
|
||||
ASSERT_EQ(clampForBitCount<int64_t>(kRandomValue, 64), kRandomValue);
|
||||
ASSERT_EQ(clampForBitCount<int64_t>(kRandomValue, 32), kRandomValue);
|
||||
ASSERT_EQ(clampForBitCount<int64_t>(kRandomValue, 16),
|
||||
static_cast<int64_t>(std::numeric_limits<int16_t>::max()));
|
||||
ASSERT_EQ(clampForBitCount<int64_t>(kRandomValue, 8),
|
||||
static_cast<int64_t>(std::numeric_limits<int8_t>::max()));
|
||||
ASSERT_EQ(clampForBitCount<int64_t>(kRandomValue, 4), 7);
|
||||
ASSERT_EQ(clampForBitCount<int64_t>(kRandomValue, 2), 1);
|
||||
ASSERT_EQ(clampForBitCount<int64_t>(kRandomValue, 0), 0);
|
||||
|
||||
ASSERT_EQ(clampForBitCount<int64_t>(kSignedMin, 64), std::numeric_limits<int64_t>::min());
|
||||
ASSERT_EQ(clampForBitCount<int64_t>(kSignedMin, 32),
|
||||
static_cast<int64_t>(std::numeric_limits<int32_t>::min()));
|
||||
ASSERT_EQ(clampForBitCount<int64_t>(kSignedMin, 16),
|
||||
static_cast<int64_t>(std::numeric_limits<int16_t>::min()));
|
||||
ASSERT_EQ(clampForBitCount<int64_t>(kSignedMin, 8),
|
||||
static_cast<int64_t>(std::numeric_limits<int8_t>::min()));
|
||||
ASSERT_EQ(clampForBitCount<int64_t>(kSignedMin, 4), -8);
|
||||
ASSERT_EQ(clampForBitCount<int64_t>(kSignedMin, 2), -2);
|
||||
ASSERT_EQ(clampForBitCount<int64_t>(kSignedMin, 0), 0);
|
||||
}
|
||||
|
||||
// Tests for float32 to float16 conversion
|
||||
TEST(MathUtilTest, Float32ToFloat16)
|
||||
{
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
//
|
||||
// Copyright 2021 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// loadtextureborder.cpp: Defines border color load functions.
|
||||
|
||||
#include "image_util/loadtextureborder.h"
|
||||
|
||||
namespace angle
|
||||
{
|
||||
|
||||
void LoadA8ToR8(angle::ColorF &mBorderColor)
|
||||
{
|
||||
mBorderColor.red = mBorderColor.alpha;
|
||||
mBorderColor.alpha = 0;
|
||||
}
|
||||
|
||||
void LoadLA8ToR8G8(angle::ColorF &mBorderColor)
|
||||
{
|
||||
mBorderColor.green = mBorderColor.alpha;
|
||||
mBorderColor.alpha = 0;
|
||||
}
|
||||
|
||||
void LoadToNative(angle::ColorF &mBorderColor) {}
|
||||
|
||||
} // namespace angle
|
||||
@@ -1,26 +0,0 @@
|
||||
//
|
||||
// Copyright 2021 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// loadtextureborder.h: Defines border color load functions.
|
||||
|
||||
#ifndef IMAGEUTIL_LOADTEXTUREBORDER_H_
|
||||
#define IMAGEUTIL_LOADTEXTUREBORDER_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "common/Color.h"
|
||||
namespace angle
|
||||
{
|
||||
|
||||
void LoadA8ToR8(angle::ColorF &mBorderColor);
|
||||
|
||||
void LoadLA8ToR8G8(angle::ColorF &mBorderColor);
|
||||
|
||||
void LoadToNative(angle::ColorF &mBorderColor);
|
||||
|
||||
} // namespace angle
|
||||
|
||||
#endif // IMAGEUTIL_LOADTEXTUREBORDER_H_
|
||||
@@ -1,155 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
# Copyright 2021 The ANGLE Project Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
#
|
||||
# gen_load_texture_border_functions_table.py:
|
||||
# Code generation for the load texture border function tables used for texture formats. These mappings are
|
||||
# not renderer specific. The mappings are done from the GL internal format, to the ANGLE format ID.
|
||||
# NOTE: don't run this script directly. Run scripts/run_code_generation.py.
|
||||
#
|
||||
|
||||
import json, sys
|
||||
|
||||
sys.path.append('../..')
|
||||
import angle_format
|
||||
|
||||
template = """// GENERATED FILE - DO NOT EDIT.
|
||||
// Generated by gen_load_texture_border_functions_table.py using data from load_texture_border_functions_data.json
|
||||
//
|
||||
// Copyright 2021 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
// load_texture_border_functions_table":
|
||||
// Contains the LoadTextureBorderFunctionMap for texture_format_util.h
|
||||
//
|
||||
|
||||
#include "libANGLE/renderer/load_texture_border_functions_table.h"
|
||||
#include "image_util/loadtextureborder.h"
|
||||
|
||||
using namespace rx;
|
||||
|
||||
namespace angle
|
||||
{{
|
||||
|
||||
namespace
|
||||
{{
|
||||
|
||||
// ES3 texture border color loading functions vary based on:
|
||||
// - the GL internal format (supplied to glTex*Image*D)
|
||||
// - the target DXGI_FORMAT that the image will be loaded into (which is chosen based on the D3D
|
||||
// device's capabilities)
|
||||
// This map type determines which loading function to use, based on these two parameters.
|
||||
// This map only contains formats which need to reorder border color channel explictly.
|
||||
|
||||
{load_functions_data}}} // namespace
|
||||
|
||||
LoadTextureBorderFunctionMap GetLoadTextureBorderFunctionsMap(GLenum {internal_format}, FormatID {angle_format})
|
||||
{{
|
||||
switch ({internal_format})
|
||||
{{
|
||||
{switch_data}
|
||||
default:
|
||||
// Use LoadToNative for any format that doesn't reorder channels.
|
||||
return DefaultLoadFunction;
|
||||
}}
|
||||
|
||||
}} // GetLoadTextureBorderFunctionsMap
|
||||
|
||||
}} // namespace angle
|
||||
"""
|
||||
|
||||
internal_format_param = 'internalFormat'
|
||||
angle_format_param = 'angleFormat'
|
||||
angle_format_unknown = 'NONE'
|
||||
|
||||
|
||||
def load_functions_name(internal_format, angle_format):
|
||||
return internal_format[3:] + "_to_" + angle_format
|
||||
|
||||
|
||||
def get_load_func(func_name, load_function):
|
||||
snippet = "LoadTextureBorderFunctionInfo " + func_name + "()\n"
|
||||
snippet += "{\n"
|
||||
snippet += " return LoadTextureBorderFunctionInfo(" + load_function + ");\n"
|
||||
snippet += "}\n"
|
||||
snippet += "\n"
|
||||
|
||||
return snippet
|
||||
|
||||
|
||||
def parse_json(json_data):
|
||||
table_data = ''
|
||||
load_functions_data = ''
|
||||
load_functions_data += get_load_func('DefaultLoadFunction', 'LoadToNative')
|
||||
for internal_format, angle_format_func in sorted(json_data["map"].items()):
|
||||
|
||||
s = ' '
|
||||
|
||||
table_data += s + 'case ' + internal_format + ':\n'
|
||||
|
||||
do_switch = len(angle_format_func) > 1 or list(
|
||||
angle_format_func)[0] != angle_format_unknown
|
||||
|
||||
if do_switch:
|
||||
table_data += s + '{\n'
|
||||
s += ' '
|
||||
table_data += s + 'switch (' + angle_format_param + ')\n'
|
||||
table_data += s + '{\n'
|
||||
s += ' '
|
||||
|
||||
for angle_format, load_function in sorted(angle_format_func.items()):
|
||||
func_name = load_functions_name(internal_format, angle_format)
|
||||
# Main case statements
|
||||
table_data += s + 'case FormatID::' + angle_format + ':\n'
|
||||
table_data += s + ' return ' + func_name + ';\n'
|
||||
|
||||
load_functions_data += get_load_func(func_name, load_function)
|
||||
|
||||
if do_switch:
|
||||
table_data += s + 'default:\n'
|
||||
table_data += s + ' return DefaultLoadFunction;\n'
|
||||
|
||||
if do_switch:
|
||||
s = s[4:]
|
||||
table_data += s + '}\n'
|
||||
s = s[4:]
|
||||
table_data += s + '}\n'
|
||||
|
||||
return table_data, load_functions_data
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
# auto_script parameters.
|
||||
if len(sys.argv) > 1:
|
||||
inputs = ['angle_format.py', 'load_texture_border_functions_data.json']
|
||||
outputs = ['load_texture_border_functions_table_autogen.cpp']
|
||||
|
||||
if sys.argv[1] == 'inputs':
|
||||
print(','.join(inputs))
|
||||
elif sys.argv[1] == 'outputs':
|
||||
print(','.join(outputs))
|
||||
else:
|
||||
print('Invalid script parameters')
|
||||
return 1
|
||||
return 0
|
||||
|
||||
json_data = angle_format.load_json('load_texture_border_functions_data.json')
|
||||
|
||||
switch_data, load_functions_data = parse_json(json_data)
|
||||
output = template.format(
|
||||
internal_format=internal_format_param,
|
||||
angle_format=angle_format_param,
|
||||
switch_data=switch_data,
|
||||
load_functions_data=load_functions_data)
|
||||
|
||||
with open('load_texture_border_functions_table_autogen.cpp', 'wt') as out_file:
|
||||
out_file.write(output)
|
||||
out_file.close()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"description": [
|
||||
"Copyright 2021 The ANGLE Project Authors. All rights reserved.",
|
||||
"Use of this source code is governed by a BSD-style license that can be",
|
||||
"found in the LICENSE file.",
|
||||
"",
|
||||
"load_texture_border_functions_data.json: Loading channel translation of border color.",
|
||||
"",
|
||||
"The format of the map is a dictionary where the key of each entry is the",
|
||||
"internal format enum, and the value is the ANGLE format enum. Note this map ",
|
||||
"only contains formats which need to reorder border color channel explictly.",
|
||||
"",
|
||||
"Also see gen_load_texture_border_functions_table.py for the code generation step."
|
||||
],
|
||||
"map":{
|
||||
"GL_ALPHA8_EXT": {
|
||||
"R8_UNORM": "LoadA8ToR8"
|
||||
},
|
||||
"GL_LUMINANCE8_ALPHA8_EXT": {
|
||||
"R8G8_UNORM": "LoadLA8ToR8G8"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
//
|
||||
// Copyright 2021 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
// load_texture_border_functions_table:
|
||||
// Contains load texture border functions table depending on internal format and ANGLE format.
|
||||
//
|
||||
|
||||
#ifndef LIBANGLE_RENDERER_LOADTEXTUREBORDERFUNCTIONSTABLE_H_
|
||||
#define LIBANGLE_RENDERER_LOADTEXTUREBORDERFUNCTIONSTABLE_H_
|
||||
|
||||
#include "libANGLE/renderer/Format.h"
|
||||
|
||||
namespace angle
|
||||
{
|
||||
rx::LoadTextureBorderFunctionMap GetLoadTextureBorderFunctionsMap(GLenum internalFormat,
|
||||
FormatID angleFormat);
|
||||
} // namespace angle
|
||||
|
||||
#endif // LIBANGLE_RENDERER_LOADTEXTUREBORDERFUNCTIONSTABLE_H_
|
||||
@@ -1,81 +0,0 @@
|
||||
// GENERATED FILE - DO NOT EDIT.
|
||||
// Generated by gen_load_texture_border_functions_table.py using data from
|
||||
// load_texture_border_functions_data.json
|
||||
//
|
||||
// Copyright 2021 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
// load_texture_border_functions_table":
|
||||
// Contains the LoadTextureBorderFunctionMap for texture_format_util.h
|
||||
//
|
||||
|
||||
#include "image_util/loadtextureborder.h"
|
||||
#include "libANGLE/renderer/load_texture_border_functions_table.h"
|
||||
|
||||
using namespace rx;
|
||||
|
||||
namespace angle
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
// ES3 texture border color loading functions vary based on:
|
||||
// - the GL internal format (supplied to glTex*Image*D)
|
||||
// - the target DXGI_FORMAT that the image will be loaded into (which is chosen based on the D3D
|
||||
// device's capabilities)
|
||||
// This map type determines which loading function to use, based on these two parameters.
|
||||
// This map only contains formats which need to reorder border color channel explictly.
|
||||
|
||||
LoadTextureBorderFunctionInfo DefaultLoadFunction()
|
||||
{
|
||||
return LoadTextureBorderFunctionInfo(LoadToNative);
|
||||
}
|
||||
|
||||
LoadTextureBorderFunctionInfo ALPHA8_EXT_to_R8_UNORM()
|
||||
{
|
||||
return LoadTextureBorderFunctionInfo(LoadA8ToR8);
|
||||
}
|
||||
|
||||
LoadTextureBorderFunctionInfo LUMINANCE8_ALPHA8_EXT_to_R8G8_UNORM()
|
||||
{
|
||||
return LoadTextureBorderFunctionInfo(LoadLA8ToR8G8);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
LoadTextureBorderFunctionMap GetLoadTextureBorderFunctionsMap(GLenum internalFormat,
|
||||
FormatID angleFormat)
|
||||
{
|
||||
switch (internalFormat)
|
||||
{
|
||||
case GL_ALPHA8_EXT:
|
||||
{
|
||||
switch (angleFormat)
|
||||
{
|
||||
case FormatID::R8_UNORM:
|
||||
return ALPHA8_EXT_to_R8_UNORM;
|
||||
default:
|
||||
return DefaultLoadFunction;
|
||||
}
|
||||
}
|
||||
case GL_LUMINANCE8_ALPHA8_EXT:
|
||||
{
|
||||
switch (angleFormat)
|
||||
{
|
||||
case FormatID::R8G8_UNORM:
|
||||
return LUMINANCE8_ALPHA8_EXT_to_R8G8_UNORM;
|
||||
default:
|
||||
return DefaultLoadFunction;
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
// Use LoadToNative for any format that doesn't reorder channels.
|
||||
return DefaultLoadFunction;
|
||||
}
|
||||
|
||||
} // GetLoadTextureBorderFunctionsMap
|
||||
|
||||
} // namespace angle
|
||||
@@ -16,7 +16,6 @@
|
||||
#include <map>
|
||||
|
||||
#include "GLSLANG/ShaderLang.h"
|
||||
#include "common/Color.h"
|
||||
#include "common/angleutils.h"
|
||||
#include "common/utilities.h"
|
||||
#include "libANGLE/angletypes.h"
|
||||
@@ -159,19 +158,7 @@ struct LoadImageFunctionInfo
|
||||
bool requiresConversion;
|
||||
};
|
||||
|
||||
using LoadFunctionMap = LoadImageFunctionInfo (*)(GLenum);
|
||||
using LoadTextureBorderFunction = void (*)(angle::ColorF &mBorderColor);
|
||||
struct LoadTextureBorderFunctionInfo
|
||||
{
|
||||
LoadTextureBorderFunctionInfo() : loadFunction(nullptr) {}
|
||||
LoadTextureBorderFunctionInfo(LoadTextureBorderFunction loadFunction)
|
||||
: loadFunction(loadFunction)
|
||||
{}
|
||||
|
||||
LoadTextureBorderFunction loadFunction;
|
||||
};
|
||||
|
||||
using LoadTextureBorderFunctionMap = LoadTextureBorderFunctionInfo (*)();
|
||||
using LoadFunctionMap = LoadImageFunctionInfo (*)(GLenum);
|
||||
|
||||
bool ShouldUseDebugLayers(const egl::AttributeMap &attribs);
|
||||
|
||||
|
||||
@@ -1451,6 +1451,82 @@ void InitializeSpecializationInfo(
|
||||
specializationInfoOut->pData = &specConsts;
|
||||
}
|
||||
|
||||
// Adjust border color value according to intended format.
|
||||
gl::ColorGeneric AdjustBorderColor(const angle::ColorGeneric &borderColorGeneric,
|
||||
const angle::Format &format)
|
||||
{
|
||||
gl::ColorGeneric adjustedBorderColor = borderColorGeneric;
|
||||
|
||||
// Handle depth formats
|
||||
if (format.hasDepthOrStencilBits())
|
||||
{
|
||||
if (format.depthBits > 0 && format.isUnorm())
|
||||
{
|
||||
// D or D/S formats
|
||||
adjustedBorderColor.colorF.red = gl::clamp01(borderColorGeneric.colorF.red);
|
||||
}
|
||||
|
||||
return adjustedBorderColor;
|
||||
}
|
||||
|
||||
// Handle LUMA formats
|
||||
if (format.isLUMA() && format.alphaBits > 0)
|
||||
{
|
||||
if (format.luminanceBits > 0)
|
||||
{
|
||||
adjustedBorderColor.colorF.green = borderColorGeneric.colorF.alpha;
|
||||
}
|
||||
else
|
||||
{
|
||||
adjustedBorderColor.colorF.red = borderColorGeneric.colorF.alpha;
|
||||
}
|
||||
|
||||
return adjustedBorderColor;
|
||||
}
|
||||
|
||||
// Handle all other formats
|
||||
if (format.isSint())
|
||||
{
|
||||
adjustedBorderColor.colorI.red =
|
||||
gl::clampForBitCount<int>(borderColorGeneric.colorI.red, format.redBits);
|
||||
adjustedBorderColor.colorI.green =
|
||||
gl::clampForBitCount<int>(borderColorGeneric.colorI.green, format.greenBits);
|
||||
adjustedBorderColor.colorI.blue =
|
||||
gl::clampForBitCount<int>(borderColorGeneric.colorI.blue, format.blueBits);
|
||||
adjustedBorderColor.colorI.alpha =
|
||||
gl::clampForBitCount<int>(borderColorGeneric.colorI.alpha, format.alphaBits);
|
||||
}
|
||||
else if (format.isUint())
|
||||
{
|
||||
adjustedBorderColor.colorUI.red =
|
||||
gl::clampForBitCount<unsigned int>(borderColorGeneric.colorUI.red, format.redBits);
|
||||
adjustedBorderColor.colorUI.green =
|
||||
gl::clampForBitCount<unsigned int>(borderColorGeneric.colorUI.green, format.greenBits);
|
||||
adjustedBorderColor.colorUI.blue =
|
||||
gl::clampForBitCount<unsigned int>(borderColorGeneric.colorUI.blue, format.blueBits);
|
||||
adjustedBorderColor.colorUI.alpha =
|
||||
gl::clampForBitCount<unsigned int>(borderColorGeneric.colorUI.alpha, format.alphaBits);
|
||||
}
|
||||
else if (format.isSnorm())
|
||||
{
|
||||
// clamp between -1.0f and 1.0f
|
||||
adjustedBorderColor.colorF.red = gl::clamp(borderColorGeneric.colorF.red, -1.0f, 1.0f);
|
||||
adjustedBorderColor.colorF.green = gl::clamp(borderColorGeneric.colorF.green, -1.0f, 1.0f);
|
||||
adjustedBorderColor.colorF.blue = gl::clamp(borderColorGeneric.colorF.blue, -1.0f, 1.0f);
|
||||
adjustedBorderColor.colorF.alpha = gl::clamp(borderColorGeneric.colorF.alpha, -1.0f, 1.0f);
|
||||
}
|
||||
else if (format.isUnorm())
|
||||
{
|
||||
// clamp between 0.0f and 1.0f
|
||||
adjustedBorderColor.colorF.red = gl::clamp01(borderColorGeneric.colorF.red);
|
||||
adjustedBorderColor.colorF.green = gl::clamp01(borderColorGeneric.colorF.green);
|
||||
adjustedBorderColor.colorF.blue = gl::clamp01(borderColorGeneric.colorF.blue);
|
||||
adjustedBorderColor.colorF.alpha = gl::clamp01(borderColorGeneric.colorF.alpha);
|
||||
}
|
||||
|
||||
return adjustedBorderColor;
|
||||
}
|
||||
|
||||
// Utility for setting a value on a packed 4-bit integer array.
|
||||
template <typename SrcT>
|
||||
void Int4Array_Set(uint8_t *arrayBytes, uint32_t arrayIndex, SrcT value)
|
||||
@@ -3407,13 +3483,11 @@ void SamplerDesc::update(ContextVk *contextVk,
|
||||
mBorderColorType =
|
||||
(samplerState.getBorderColor().type == angle::ColorGeneric::Type::Float) ? 0 : 1;
|
||||
|
||||
// Adjust border color according to intended format
|
||||
const vk::Format &vkFormat = contextVk->getRenderer()->getFormat(intendedFormatID);
|
||||
mBorderColor = samplerState.getBorderColor().colorF;
|
||||
if (vkFormat.getIntendedFormatID() != angle::FormatID::NONE)
|
||||
{
|
||||
LoadTextureBorderFunctionInfo loadFunction = vkFormat.getTextureBorderLoadFunctions();
|
||||
loadFunction.loadFunction(mBorderColor);
|
||||
}
|
||||
gl::ColorGeneric adjustedBorderColor =
|
||||
AdjustBorderColor(samplerState.getBorderColor(), vkFormat.getIntendedFormat());
|
||||
mBorderColor = adjustedBorderColor.colorF;
|
||||
|
||||
mReserved = 0;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "libANGLE/Texture.h"
|
||||
#include "libANGLE/formatutils.h"
|
||||
#include "libANGLE/renderer/load_functions_table.h"
|
||||
#include "libANGLE/renderer/load_texture_border_functions_table.h"
|
||||
#include "libANGLE/renderer/vulkan/ContextVk.h"
|
||||
#include "libANGLE/renderer/vulkan/RendererVk.h"
|
||||
#include "libANGLE/renderer/vulkan/vk_caps_utils.h"
|
||||
@@ -280,8 +279,6 @@ void FormatTable::initialize(RendererVk *renderer,
|
||||
{
|
||||
format.mTextureLoadFunctions = GetLoadFunctionsMap(
|
||||
format.mIntendedGLFormat, format.mActualSampleOnlyImageFormatID);
|
||||
format.mTextureBorderLoadFunctions = GetLoadTextureBorderFunctionsMap(
|
||||
format.mIntendedGLFormat, format.mActualSampleOnlyImageFormatID);
|
||||
}
|
||||
|
||||
if (format.mActualRenderableImageFormatID == format.mActualSampleOnlyImageFormatID)
|
||||
|
||||
@@ -116,10 +116,6 @@ class Format final : private angle::NonCopyable
|
||||
: mTextureLoadFunctions(type);
|
||||
}
|
||||
|
||||
LoadTextureBorderFunctionInfo getTextureBorderLoadFunctions() const
|
||||
{
|
||||
return mTextureBorderLoadFunctions();
|
||||
}
|
||||
// The actual Buffer format is used to implement the front-end format for Buffers. This format
|
||||
// is used by vertex buffers as well as texture buffers. Note that all formats required for
|
||||
// GL_EXT_texture_buffer have mandatory support for vertex buffers in Vulkan, so they won't be
|
||||
@@ -191,7 +187,6 @@ class Format final : private angle::NonCopyable
|
||||
|
||||
InitializeTextureDataFunction mImageInitializerFunction;
|
||||
LoadFunctionMap mTextureLoadFunctions;
|
||||
LoadTextureBorderFunctionMap mTextureBorderLoadFunctions;
|
||||
LoadFunctionMap mRenderableTextureLoadFunctions;
|
||||
VertexCopyFunction mVertexLoadFunction;
|
||||
VertexCopyFunction mCompressedVertexLoadFunction;
|
||||
|
||||
@@ -128,7 +128,6 @@ libangle_image_util_headers = [
|
||||
"src/image_util/imageformats.h",
|
||||
"src/image_util/loadimage.h",
|
||||
"src/image_util/loadimage.inc",
|
||||
"src/image_util/loadtextureborder.h",
|
||||
]
|
||||
|
||||
libangle_image_util_sources = [
|
||||
@@ -136,7 +135,6 @@ libangle_image_util_sources = [
|
||||
"src/image_util/imageformats.cpp",
|
||||
"src/image_util/loadimage.cpp",
|
||||
"src/image_util/loadimage_etc.cpp",
|
||||
"src/image_util/loadtextureborder.cpp",
|
||||
]
|
||||
|
||||
libangle_gpu_info_util_sources = [
|
||||
@@ -327,7 +325,6 @@ libangle_headers = [
|
||||
"src/libANGLE/renderer/copyvertex.h",
|
||||
"src/libANGLE/renderer/copyvertex.inc.h",
|
||||
"src/libANGLE/renderer/load_functions_table.h",
|
||||
"src/libANGLE/renderer/load_texture_border_functions_table.h",
|
||||
"src/libANGLE/renderer/renderer_utils.h",
|
||||
"src/libANGLE/renderer/serial_utils.h",
|
||||
"src/libANGLE/validationEGL.h",
|
||||
@@ -429,7 +426,6 @@ libangle_sources = [
|
||||
"src/libANGLE/renderer/TextureImpl.cpp",
|
||||
"src/libANGLE/renderer/driver_utils.cpp",
|
||||
"src/libANGLE/renderer/load_functions_table_autogen.cpp",
|
||||
"src/libANGLE/renderer/load_texture_border_functions_table_autogen.cpp",
|
||||
"src/libANGLE/renderer/renderer_utils.cpp",
|
||||
"src/libANGLE/validationEGL.cpp",
|
||||
"src/libANGLE/validationES.cpp",
|
||||
|
||||
Reference in New Issue
Block a user