mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-15 07:29:17 +01:00
[dxvk] Add convenience function to query default resolve mode
Removes some code duplication.
This commit is contained in:
parent
fd9b561100
commit
292a0b498a
@ -1961,11 +1961,7 @@ namespace dxvk {
|
|||||||
if (useRp) {
|
if (useRp) {
|
||||||
// Work out resolve mode based on format properties. For color images,
|
// Work out resolve mode based on format properties. For color images,
|
||||||
// we must use AVERAGE unless the resolve uses an integer format.
|
// we must use AVERAGE unless the resolve uses an integer format.
|
||||||
VkResolveModeFlagBits mode = VK_RESOLVE_MODE_AVERAGE_BIT;
|
VkResolveModeFlagBits mode = getDefaultResolveMode(formatInfo);
|
||||||
|
|
||||||
if (formatInfo->flags.any(DxvkFormatFlag::SampledSInt, DxvkFormatFlag::SampledUInt)
|
|
||||||
|| (formatInfo->aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)))
|
|
||||||
mode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
|
|
||||||
|
|
||||||
this->resolveImageRp(dstImage, srcImage, region,
|
this->resolveImageRp(dstImage, srcImage, region,
|
||||||
format, mode, mode);
|
format, mode, mode);
|
||||||
@ -7777,17 +7773,12 @@ namespace dxvk {
|
|||||||
// Always do a SAMPLE_ZERO resolve here since that's less expensive and closer to what
|
// Always do a SAMPLE_ZERO resolve here since that's less expensive and closer to what
|
||||||
// happens on native AMD anyway. Need to use a shader in case we are dealing with a
|
// happens on native AMD anyway. Need to use a shader in case we are dealing with a
|
||||||
// non-integer color image since render pass resolves only support AVERAGE.
|
// non-integer color image since render pass resolves only support AVERAGE.
|
||||||
auto formatInfo = lookupFormatInfo(op.resolveFormat);
|
if (getDefaultResolveMode(op.resolveFormat) == VK_RESOLVE_MODE_SAMPLE_ZERO_BIT) {
|
||||||
|
|
||||||
bool useRp = (formatInfo->flags.any(DxvkFormatFlag::SampledSInt, DxvkFormatFlag::SampledUInt))
|
|
||||||
|| (formatInfo->aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT));
|
|
||||||
|
|
||||||
if (useRp) {
|
|
||||||
resolveImageRp(op.resolveImage, op.inputImage, op.resolveRegion,
|
resolveImageRp(op.resolveImage, op.inputImage, op.resolveRegion,
|
||||||
op.resolveFormat, VK_RESOLVE_MODE_SAMPLE_ZERO_BIT, VK_RESOLVE_MODE_SAMPLE_ZERO_BIT);
|
op.resolveFormat, VK_RESOLVE_MODE_SAMPLE_ZERO_BIT, VK_RESOLVE_MODE_SAMPLE_ZERO_BIT);
|
||||||
} else {
|
} else {
|
||||||
resolveImageFb(op.resolveImage, op.inputImage, op.resolveRegion,
|
resolveImageFb(op.resolveImage, op.inputImage, op.resolveRegion,
|
||||||
op.resolveFormat, VK_RESOLVE_MODE_SAMPLE_ZERO_BIT, VK_RESOLVE_MODE_NONE);
|
op.resolveFormat, VK_RESOLVE_MODE_SAMPLE_ZERO_BIT, VK_RESOLVE_MODE_SAMPLE_ZERO_BIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,4 +114,23 @@ namespace dxvk {
|
|||||||
return lookupFormatInfoSlow(format);
|
return lookupFormatInfoSlow(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Queries default resolve mode for format
|
||||||
|
*
|
||||||
|
* For depth-stencil formats, this will return SAMPLE_ZERO.
|
||||||
|
* \param [in] format Format to look up
|
||||||
|
* \returns Default resolve mode
|
||||||
|
*/
|
||||||
|
inline VkResolveModeFlagBits getDefaultResolveMode(const DxvkFormatInfo* format) {
|
||||||
|
if ((format->aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT))
|
||||||
|
|| (format->flags.any(DxvkFormatFlag::SampledSInt, DxvkFormatFlag::SampledUInt)))
|
||||||
|
return VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
|
||||||
|
|
||||||
|
return VK_RESOLVE_MODE_AVERAGE_BIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline VkResolveModeFlagBits getDefaultResolveMode(VkFormat format) {
|
||||||
|
return getDefaultResolveMode(lookupFormatInfo(format));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user