mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-10-12 15:19:17 +00:00
ASTC adjustments
This commit is contained in:
@@ -77,14 +77,8 @@ uvec4 local_buff;
|
|||||||
uvec4 color_endpoint_data;
|
uvec4 color_endpoint_data;
|
||||||
int color_bitsread = 0;
|
int color_bitsread = 0;
|
||||||
|
|
||||||
// Global "vector" to be pushed into when decoding
|
#define MAX_WEIGHT_VALUES 64
|
||||||
// At most will require BLOCK_WIDTH x BLOCK_HEIGHT in single plane mode
|
uint result_vector[MAX_WEIGHT_VALUES];
|
||||||
// At most will require BLOCK_WIDTH x BLOCK_HEIGHT x 2 in dual plane mode
|
|
||||||
// So the maximum would be 144 (12 x 12) elements, x 2 for two planes
|
|
||||||
#define DIVCEIL(number, divisor) (number + divisor - 1) / divisor
|
|
||||||
#define ARRAY_NUM_ELEMENTS 144
|
|
||||||
#define VECTOR_ARRAY_SIZE DIVCEIL(ARRAY_NUM_ELEMENTS * 2, 4)
|
|
||||||
uint result_vector[ARRAY_NUM_ELEMENTS * 2];
|
|
||||||
|
|
||||||
int result_index = 0;
|
int result_index = 0;
|
||||||
uint result_vector_max_index;
|
uint result_vector_max_index;
|
||||||
@@ -492,7 +486,7 @@ void DecodeColorValues(uvec4 modes, uint num_partitions, uint color_data_bits, o
|
|||||||
A = ReplicateBitTo9((bitval & 1));
|
A = ReplicateBitTo9((bitval & 1));
|
||||||
switch (encoding) {
|
switch (encoding) {
|
||||||
case JUST_BITS:
|
case JUST_BITS:
|
||||||
color_values[++out_index] = FastReplicateTo8(bitval, bitlen);
|
color_values[out_index++] = FastReplicateTo8(bitval, bitlen);
|
||||||
break;
|
break;
|
||||||
case TRIT: {
|
case TRIT: {
|
||||||
D = QuintTritValue(val);
|
D = QuintTritValue(val);
|
||||||
@@ -571,7 +565,7 @@ void DecodeColorValues(uvec4 modes, uint num_partitions, uint color_data_bits, o
|
|||||||
uint T = (D * C) + B;
|
uint T = (D * C) + B;
|
||||||
T ^= A;
|
T ^= A;
|
||||||
T = (A & 0x80) | (T >> 2);
|
T = (A & 0x80) | (T >> 2);
|
||||||
color_values[++out_index] = T;
|
color_values[out_index++] = T;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -753,12 +747,12 @@ void ComputeEndpoints(out uvec4 ep1, out uvec4 ep2, uint color_endpoint_mode, ui
|
|||||||
#define READ_UINT_VALUES(N) \
|
#define READ_UINT_VALUES(N) \
|
||||||
uvec4 V[2]; \
|
uvec4 V[2]; \
|
||||||
for (uint i = 0; i < N; i++) { \
|
for (uint i = 0; i < N; i++) { \
|
||||||
V[i / 4][i % 4] = color_values[++colvals_index]; \
|
V[i / 4][i % 4] = color_values[colvals_index++]; \
|
||||||
}
|
}
|
||||||
#define READ_INT_VALUES(N) \
|
#define READ_INT_VALUES(N) \
|
||||||
ivec4 V[2]; \
|
ivec4 V[2]; \
|
||||||
for (uint i = 0; i < N; i++) { \
|
for (uint i = 0; i < N; i++) { \
|
||||||
V[i / 4][i % 4] = int(color_values[++colvals_index]); \
|
V[i / 4][i % 4] = int(color_values[colvals_index++]); \
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (color_endpoint_mode) {
|
switch (color_endpoint_mode) {
|
||||||
@@ -1225,6 +1219,10 @@ void DecompressBlock(ivec3 coord) {
|
|||||||
FillError(coord);
|
FillError(coord);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (GetNumWeightValues(size_params, dual_plane) > MAX_WEIGHT_VALUES) {
|
||||||
|
FillError(coord);
|
||||||
|
return;
|
||||||
|
}
|
||||||
uint partition_index = 1;
|
uint partition_index = 1;
|
||||||
uvec4 color_endpoint_mode = uvec4(0);
|
uvec4 color_endpoint_mode = uvec4(0);
|
||||||
uint ced_pointer = 0;
|
uint ced_pointer = 0;
|
||||||
|
|||||||
@@ -270,6 +270,10 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool IsLdrAstcFormat(VkFormat format) {
|
||||||
|
return format >= VK_FORMAT_ASTC_4x4_UNORM_BLOCK && format <= VK_FORMAT_ASTC_12x12_SRGB_BLOCK;
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] VkImageAspectFlags ImageViewAspectMask(const VideoCommon::ImageViewInfo& info) {
|
[[nodiscard]] VkImageAspectFlags ImageViewAspectMask(const VideoCommon::ImageViewInfo& info) {
|
||||||
if (info.IsRenderTarget()) {
|
if (info.IsRenderTarget()) {
|
||||||
return ImageAspectMask(info.format);
|
return ImageAspectMask(info.format);
|
||||||
@@ -2483,9 +2487,18 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI
|
|||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
.usage = clamped_view_usage,
|
.usage = clamped_view_usage,
|
||||||
};
|
};
|
||||||
|
const VkImageViewASTCDecodeModeEXT astc_decode_mode{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_ASTC_DECODE_MODE_EXT,
|
||||||
|
.pNext = &image_view_usage,
|
||||||
|
.decodeMode = VK_FORMAT_R8G8B8A8_UNORM,
|
||||||
|
};
|
||||||
|
const void* view_next = &image_view_usage;
|
||||||
|
if (device->IsExtAstcDecodeModeSupported() && IsLdrAstcFormat(format_info.format)) {
|
||||||
|
view_next = &astc_decode_mode;
|
||||||
|
}
|
||||||
const VkImageViewCreateInfo create_info{
|
const VkImageViewCreateInfo create_info{
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
||||||
.pNext = &image_view_usage,
|
.pNext = view_next,
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.image = image.Handle(),
|
.image = image.Handle(),
|
||||||
.viewType = VkImageViewType{},
|
.viewType = VkImageViewType{},
|
||||||
|
|||||||
@@ -953,8 +953,7 @@ bool Device::ComputeIsOptimalAstcSupported() const {
|
|||||||
VK_FORMAT_ASTC_12x10_UNORM_BLOCK, VK_FORMAT_ASTC_12x10_SRGB_BLOCK,
|
VK_FORMAT_ASTC_12x10_UNORM_BLOCK, VK_FORMAT_ASTC_12x10_SRGB_BLOCK,
|
||||||
VK_FORMAT_ASTC_12x12_UNORM_BLOCK, VK_FORMAT_ASTC_12x12_SRGB_BLOCK,
|
VK_FORMAT_ASTC_12x12_UNORM_BLOCK, VK_FORMAT_ASTC_12x12_SRGB_BLOCK,
|
||||||
};
|
};
|
||||||
if (!features.features.textureCompressionASTC_LDR ||
|
if (!features.features.textureCompressionASTC_LDR) {
|
||||||
!features.texture_compression_astc_hdr.textureCompressionASTC_HDR) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto format_feature_usage{VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT |
|
const auto format_feature_usage{VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT |
|
||||||
@@ -1505,6 +1504,12 @@ void Device::RemoveUnsuitableExtensions() {
|
|||||||
features.subgroup_size_control,
|
features.subgroup_size_control,
|
||||||
VK_EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME);
|
VK_EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME);
|
||||||
|
|
||||||
|
// VK_EXT_texture_compression_astc_hdr
|
||||||
|
extensions.texture_compression_astc_hdr = false;
|
||||||
|
RemoveExtensionFeatureIfUnsuitable(extensions.texture_compression_astc_hdr,
|
||||||
|
features.texture_compression_astc_hdr,
|
||||||
|
VK_EXT_TEXTURE_COMPRESSION_ASTC_HDR_EXTENSION_NAME);
|
||||||
|
|
||||||
// VK_EXT_transform_feedback
|
// VK_EXT_transform_feedback
|
||||||
extensions.transform_feedback =
|
extensions.transform_feedback =
|
||||||
features.transform_feedback.transformFeedback &&
|
features.transform_feedback.transformFeedback &&
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ VK_DEFINE_HANDLE(VmaAllocator)
|
|||||||
|
|
||||||
// Define miscellaneous extensions which may be used by the implementation here.
|
// Define miscellaneous extensions which may be used by the implementation here.
|
||||||
#define FOR_EACH_VK_EXTENSION(EXTENSION) \
|
#define FOR_EACH_VK_EXTENSION(EXTENSION) \
|
||||||
|
EXTENSION(EXT, ASTC_DECODE_MODE, astc_decode_mode) \
|
||||||
EXTENSION(EXT, CONDITIONAL_RENDERING, conditional_rendering) \
|
EXTENSION(EXT, CONDITIONAL_RENDERING, conditional_rendering) \
|
||||||
EXTENSION(EXT, CONSERVATIVE_RASTERIZATION, conservative_rasterization) \
|
EXTENSION(EXT, CONSERVATIVE_RASTERIZATION, conservative_rasterization) \
|
||||||
EXTENSION(EXT, DEPTH_RANGE_UNRESTRICTED, depth_range_unrestricted) \
|
EXTENSION(EXT, DEPTH_RANGE_UNRESTRICTED, depth_range_unrestricted) \
|
||||||
@@ -911,10 +912,17 @@ FN_MAX_LIMIT_LIST
|
|||||||
features.shader_atomic_int64.shaderSharedInt64Atomics;
|
features.shader_atomic_int64.shaderSharedInt64Atomics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns true if the device supports VK_EXT_conditional_rendering.
|
||||||
bool IsExtConditionalRendering() const {
|
bool IsExtConditionalRendering() const {
|
||||||
return extensions.conditional_rendering;
|
return extensions.conditional_rendering;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns true if the device supports VK_EXT_astc_decode_mode.
|
||||||
|
bool IsExtAstcDecodeModeSupported() const {
|
||||||
|
return extensions.astc_decode_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns true if the device supports VK_EXT_external_memory_host.
|
||||||
bool IsExtExternalMemoryHostSupported() const {
|
bool IsExtExternalMemoryHostSupported() const {
|
||||||
return extensions.external_memory_host;
|
return extensions.external_memory_host;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user