Skip to content

Commit 4b4d30e

Browse files
authored
Merge pull request hrydgard#19748 from hrydgard/software-depth-proto
Render a software depth buffer in parallel with HW rendering
2 parents bff2498 + 80cb57f commit 4b4d30e

33 files changed

Lines changed: 1074 additions & 25 deletions

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,6 +1906,8 @@ set(GPU_SOURCES
19061906
GPU/Common/Draw2D.cpp
19071907
GPU/Common/Draw2D.h
19081908
GPU/Common/DepthBufferCommon.cpp
1909+
GPU/Common/DepthRaster.cpp
1910+
GPU/Common/DepthRaster.h
19091911
GPU/Common/TextureShaderCommon.cpp
19101912
GPU/Common/TextureShaderCommon.h
19111913
GPU/Common/DepalettizeShaderCommon.cpp

Common/Data/Convert/ColorConv.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void ConvertBGRA8888ToRGB888(u8 *dst, const u32 *src, u32 numPixels) {
6565
}
6666

6767
#if PPSSPP_ARCH(SSE2)
68-
// fp64's improved version, see #19751
68+
// fp64's improved SSE2 version, see #19751. SSE4 no longer required here.
6969
static inline void ConvertRGBA8888ToRGBA5551(__m128i *dstp, const __m128i *srcp, u32 sseChunks) {
7070
const __m128i maskRB = _mm_set1_epi32(0x00F800F8);
7171
const __m128i maskGA = _mm_set1_epi32(0x8000F800);
@@ -76,7 +76,7 @@ static inline void ConvertRGBA8888ToRGBA5551(__m128i *dstp, const __m128i *srcp,
7676
__m128i c0 = _mm_load_si128(&srcp[i + 0]);
7777
__m128i c1 = _mm_load_si128(&srcp[i + 1]);
7878

79-
__m128i rb0 = _mm_and_si128(c0, maskRB); // 00000000bbbbb00000000000rrrrr000
79+
__m128i rb0 = _mm_and_si128(c0, maskRB); // 00000000bbbbb00000000000rrrrr000 (each 32-bit lane)
8080
__m128i rb1 = _mm_and_si128(c1, maskRB); // 00000000bbbbb00000000000rrrrr000
8181
__m128i ga0 = _mm_and_si128(c0, maskGA); // a000000000000000ggggg00000000000
8282
__m128i ga1 = _mm_and_si128(c1, maskGA); // a000000000000000ggggg00000000000

Common/GPU/DataFormat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ bool DataFormatIsDepthStencil(DataFormat fmt);
7474
inline bool DataFormatIsColor(DataFormat fmt) {
7575
return !DataFormatIsDepthStencil(fmt);
7676
}
77+
int DataFormatNumChannels(DataFormat fmt);
7778
bool DataFormatIsBlockCompressed(DataFormat fmt, int *blockSize);
7879

7980
// Limited format support for now.

Common/GPU/Vulkan/thin3d_vulkan.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,9 +803,15 @@ bool VKTexture::Create(VkCommandBuffer cmd, VulkanBarrierBatch *postBarriers, Vu
803803
}
804804

805805
VkComponentMapping r8AsAlpha[4] = { VK_COMPONENT_SWIZZLE_ONE, VK_COMPONENT_SWIZZLE_ONE, VK_COMPONENT_SWIZZLE_ONE, VK_COMPONENT_SWIZZLE_R };
806+
VkComponentMapping r8AsColor[4] = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_ONE };
806807

808+
VkComponentMapping *swizzle = nullptr;
809+
switch (desc.swizzle) {
810+
case TextureSwizzle::R8_AS_ALPHA: swizzle = r8AsAlpha; break;
811+
case TextureSwizzle::R8_AS_GRAYSCALE: swizzle = r8AsColor; break;
812+
}
807813
VulkanBarrierBatch barrier;
808-
if (!vkTex_->CreateDirect(width_, height_, 1, mipLevels_, vulkanFormat, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, usageBits, &barrier, desc.swizzle == TextureSwizzle::R8_AS_ALPHA ? r8AsAlpha : nullptr)) {
814+
if (!vkTex_->CreateDirect(width_, height_, 1, mipLevels_, vulkanFormat, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, usageBits, &barrier, swizzle)) {
809815
ERROR_LOG(Log::G3D, "Failed to create VulkanTexture: %dx%dx%d fmt %d, %d levels", width_, height_, depth_, (int)vulkanFormat, mipLevels_);
810816
return false;
811817
}

Common/GPU/thin3d.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,25 @@ bool DataFormatIsBlockCompressed(DataFormat fmt, int *blockSize) {
118118
}
119119
}
120120

121+
int DataFormatNumChannels(DataFormat fmt) {
122+
switch (fmt) {
123+
case DataFormat::D16:
124+
case DataFormat::D32F:
125+
case DataFormat::R8_UNORM:
126+
case DataFormat::R16_UNORM:
127+
case DataFormat::R16_FLOAT:
128+
case DataFormat::R32_FLOAT:
129+
return 1;
130+
case DataFormat::R8G8B8A8_UNORM:
131+
case DataFormat::R8G8B8A8_UNORM_SRGB:
132+
case DataFormat::B8G8R8A8_UNORM:
133+
case DataFormat::B8G8R8A8_UNORM_SRGB:
134+
return 4;
135+
default:
136+
return 0;
137+
}
138+
}
139+
121140
RefCountedObject::~RefCountedObject() {
122141
const int rc = refcount_.load();
123142
_dbg_assert_msg_(rc == 0xDEDEDE, "Unexpected refcount %d in object of type '%s'", rc, name_);

Common/GPU/thin3d.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ typedef std::function<bool(uint8_t *data, const uint8_t *initData, uint32_t w, u
643643
enum class TextureSwizzle {
644644
DEFAULT,
645645
R8_AS_ALPHA,
646+
R8_AS_GRAYSCALE,
646647
};
647648

648649
struct TextureDesc {

0 commit comments

Comments
 (0)