Skip to content

Commit

Permalink
Update readme.md (#5)
Browse files Browse the repository at this point in the history
* Adds two new tests to GPU driver test screen: Adreno shader logic test and flat shading

The adreno test tests for the bug mentioned in hrydgard#13910.
Very clear repro on Adreno 630, Pocophone F1.

The flat shading test is an untested attempt at a repro of

(will test that tomomorrow).

* Add texture to flat shaded test.

* Compat: Note that 3 LEGO games those are require Buffered rendering

* More GPU test improvements

* Fix the flat test. Unfortunately doesn't repro the bug :(

* GL FB readback: Only use "inout" if we actually want to read from the fb.

* Headless: Allow screenshot compare without backend.

This makes not just graphics-enabled tests work in headless on softgpu,
but also screenshot comparison ones.

* Headless: Read expected file as a FileLoader.

This makes it possible to run tests from network locations.

* Headless: Allow PNGs and http:// for screenshot.

* Headless: Disable http disk cache.

* Headless: Simplify executing a ppdmp via headless.

* Headless: Default to PNG for ppdmp tests.

* GPU: Fix safe size checks when rect offscreen.

* Vulkan: Prevent scaling shader leak.

No need to recreate if they haven't changed.

* Compat: Enable reinterpret for Kingdom Hearts.

See hrydgard#11223.  Should enable it for everything at some point.

* Debugger: Add API to trigger buttons.

* Debugger: Broadcast ctrl input events.

This can be useful to trigger debugging functionality on button press.

* Debugger: Include all press states for convenience.

In case of a multi-button shortcut, which might be common for debugging.

* Kernel: Adjust sceKernelGetThreadExitStatus timing.

See hrydgard#13703.

* PGF Fixed Bold & Italic property and camouflage the Font name.

* Oops! I misstook uploading jpn0.pgf.

* Resample all mp3

Fix hrydgard#5213

* Fix Russian (Cyrillic alphabet) on jpn0.pgf.

* Some marks position fixed on jpn0.pgf

* build fix

* PPGe: Scale down by worst of window/internal res.

See hrydgard#13958.

* compat.ini: Add Split/Second to [ReinterpretFramebuffers]. See hrydgard#13957

* Plugins: Enable by default.

* Resample only in 32000Hz

* Fix Greek characters & Roman numbers & all balance on jpn0.pgf

* Do PtpConnect internally during PtpOpen, since some games (ie. The Warriors) seems to do PtpSend immediately after PtpOpen without trying to PtpConnect first.

* Fix returned error code on PtpSend and PtpRecv when socket is not connected yet.

* OpenGL fragment shader gen: Fix precision inconsistency for v_color0/1.

Probably won't fix anything, just want this in for, well, consistency.

Noticed it debugging the iOS flat shading issues, but doesn't fix that.

* Fix duplicate shader version in the flat shader test

Unbreaks the flat shading test on Adreno (ended up in trying to link a
 #version 300 and a #version 320 shader together which it didn't like)

* Io: Don't allow async close while async busy.

See hrydgard#6582.

* GE: Better naming of render passes for color reinterpret

* GPU: Respect stencil write mask for 5551 buffers.

If the mask is 0x7F on 5551, that's equivalent to allowing the clear
entirely.  See hrydgard#13391.

* D3D9: Don't allow separate alpha clears.

Doesn't seem like the color mask applies to clears.

* Reporting: Expose CRC queue methods for other uses.

This way UI can expose the CRC if needed.

* Don't allow ForcedFirstConnect hack when using PtpConnect within PtpOpen to prevent returning result from blocking PtpConnect instead of result of PtpOpen.

* sceMp3Init:Add layerBits and versionBits information

* Add header information

* GLES: Remove direct khrplatform.h header include.

Shouldn't be needed anymore, was a hack for Nokia.  See hrydgard#13978.

* Mp3: Correct error handling for newer sdk versions.

The 6.xx behavior might be important if a game relies on it to add data.

* Mp3: Allow decode without pcm pointer.

Just like other audio decoding, you're allowed to skip audio.
Also prevents a crash if the mp3 is not yet inited.

* Add back XCode TARGETED_DEVICE_FAMILY config line

xcode warns that the value is deprecated or something, but maybe it still does something. Appears iPad support is broken right now.

* Mp3: Always keep sample rate from original mp3.

Our codec context is updated with the source sample rate, so this makes us
not resample at all.

Converting to stereo still seems correct.

* Updated GameMode initial data sync, in case remote players aren't listening yet when sending initial data (fix Pocket Pool)

* Mp3: Correct logging for init.

* Remove duplicates from ThreadManForKernel

* Vulkan: Add MMPX upscaling texture shader.

See https://casual-effects.com/research/McGuire2021PixelArt/index.html

* Vulkan: Allow tex shaders to specify a max scale.

* Specify MaxScale=2 for the new MMPX texture scaling shader

* Fix Greek characters ltn0~7.pgf

* gitlab ci change requested by m4xw

* FindFFmpeg: Fix a few issues

1. postproc now looks for postprocess.h (there is no postproc.h header).
2. pkg-config fallback condition now works (find_path/library set the
   variable to ${var}-NOTFOUND but it was checking for an empty string).

* (.gitlab-ci.yml) Add windows-x64 target

* Mpeg:Only allow firmware >= 3 for warmup

Fix hrydgard#13996

* Try to build fix on non-windows

* CMake: Add USE_UBSAN

* CMake: Rename USE_ADDRESS_SANITIZER to USE_ASAN

For consistency with USE_UBSAN

* CMake: Fix UBSAN link error

* Fix Russian characters ltn8~15.pgf

* Fix alignment issues in ISOFileSystem

Fixes hrydgard#14002

* jit: Make branch shift more obvious.

And also not technically undefined behavior.

* Fix connection issue on Dynasty Warriors (Shin Sangoku Musou) games when playing with more than 2 players.

* Minimize the Adreno shader compiler bug repro test

* Fix left shift of negative value in MIPSCodeUtils

Fixes a benign UBSAN error to improve the signal-to-noise ratio of
UBSAN errors.

Fixes hrydgard#14015

* x64Emitter: Fix unaligned store UBSAN errors

This compiles to the same assembly as before even without optimizations and avoids UB.

https://godbolt.org/z/4G5edM

While the UB here is benign, this improves signal-to-noise ratio of UBSAN errors.

Fixes hrydgard#14005

* Fix logging flags

1. The logging flags were being ignored (-v, -d)
2. Adds a `--loglevel` argument. Useful when using the debug build for
   ASAN/UBSAN to hide extremely noisy debug messages.

* Attempt to fix hrydgard#14022

* Fix Apple gpu detection

* Core: Correct branch analysis truncation.

* jit: Be very clear on sign extension.

* Only force the log level if it set via an argv

Follow-up to hrydgard#14019

* Io: Consistently use LE values of ISO entries.

Better to be consistent across big endian and little endian, in case
something was mastered wrong.

* Vulkan: Fix image layout issues after compute shader uploads.

We're already in GENERAL so probably not worth to transfer to DST just
to do even more transfers due to the silliness of GenerateMip.

I'm planning to rework the whole texture upload thing to be far more
optimal with some kind of TextureUploadManager

Fixes hrydgard#13987

* Mpeg:Only allow firmware >= 6 for warmup

Fix blue screen in hrydgard#13146

* Ge: Improve some logging and memchecks.

Explicitly trigger memchecks on readback.

* Ge: Restore saved context when ending a list.

Otherwise another list queued by a Head push could use the wrong context
data.  See hrydgard#13346.

* Framedump test screen. Downloads a list of framedumps.

* Add a new command in developer tools to list and load framedumps from framedump.ppsspp.org/repro/

Useful to make it easy to test GPU driver bugs etc, without having to
use real games or copying files around.

* Add checkbox to enable/disable driver bug workarounds.

* Fix minor rendering glitch in PPSSPP's menus on iOS

* Have the flat shading workaround obey the driver workarounds checkbox

* Loaders: Prevent errors on 0 byte reads.

Was happening when opening an http:// GE frame dump.

* Core: Maintain frame dump disc ID in SFO.

This way we won't generate a fake one later and use it for anything else.

* vertexjit: Correct saved registers on x64.

* Core: Assert debug stats remain positive.

* vertexjit: Only save extra regs on x64.

* Updated PdpStat and PtpStat

* Update README.md for 1.11

* Address initial feedback by iota97

* List fixed games. Thanks sum2012

* More from unknown and sum2012

* More stuff in README.md

* (.gitlab-ci.yml) Add linux-i686 and windows-i686 targets (+ prevent creation of 'null' file when building Windows libretro cores)

* Fix possible lock issue during AdhocMatchingStart

* Updated PdpStat to prevent rcv_sb_cc from exceeding the buffer size arg (since we use larger buffer size to prevent micro stutters or disconnection issue due to too many dropped packets with small buffer size).
TODO: May need to improve it to be able to calculate the correct size if there are multiple datagram messages

* UI: Correct developer tools test run.

* Make a couple of UI animations refresh rate independent

* Core: Reset state properly on CPU init failure.

* Windows: Prevent crash on null symbol map.

Happened during a double error scenario, but might as well check.

* We don't really need to allocate a buffer when using MSG_TRUNC on recvfrom

* Minor renaming

* Moving hleDelayResult from internal function of SetSocketAlert to prevent waking up HLE-blocked thread

* Fix possible race condition issue.

* Fix jpn0.pgf characters position.

* Debugger: Populate funcs if disassembly open early.

* PPGe: Fallback to atlas text on alloc fail.

* PPGe: Clear text allocations on shutdown.

* Updated some Logs to help finding the location of the call to debug.

* Removing hleDelayResult from internal adhoc functions to prevent waking up thread that supposed to be blocked by the outer HLE.

* Run the link script

* Run the link script, fixups

* Update lang,pspautotests submodules

* Do the title screen animation by accumulator instead, to avoid a long first frame breaking it.

* Update version to 1.11

* PPGe: Decimate text images properly.

* Add more games to ReportSmallMemStick

* Handle exec addr errors better - don't let IgnoreBadMemoryAccesses skip dispatcher exceptions.

It would then just fall through into the compiler and die.

Should remove one of the "mystery" crashes from hrydgard#14082.

* Cause the correct type of exception. Never ignore EXEC_ADDR exceptions.

* Buildfix

* GL: Call CreateDeviceObjects *after* updating render_.

Also remove a redundant call to fetch render_ in the constructor, it's
already passed in.

* Remove now-redundant check

* Only allow sceMpegGetAvcAu warmup for God Eater Series

Fix hrydgard#14086

* Rename the new warmup variable from hrydgard#14091

* SaveState: Prevent crash on bad cookie marker.

Just fail to load the save state.

* Update lang submodule (it_IT updates)

* Remove a completely unnecessary check in BackgroundAudio.cpp that caused glitching at 44.1khz.

Fixes hrydgard#14096

* Assorted paranoid cleanups, inspired by hrydgard#14082

* Fix frozen (0 FPS) issue on Kao Challengers and Asterix & Obelix XX (probably also fix other games from the same developer with similar issue) hrydgard#14103

* Windows recvfrom doesn't support MSG_TRUNC, so we're using dummy buffer with max size as alternative for peeking actual size of the next pending message.

* Update zh_CN and zh_TW

* Fix lobby issue on The Warriors, probably also fix similar issue on other games too.

* Update README.md for 1.11.1

* Slight simplification in LogoScreen

Not that I think those crashes actually are from this...

* Update version to 1.11.1

* Some GLSL compilers are very particular about the sign of shift operands..

* Revert (partially) "compat.ini: Add Split/Second to [ReinterpretFramebuffers]. See hrydgard#13957"

Also see hrydgard#14123 . Not sure I intended to actually do this.

This reverts commit d0c3a5a.

* GPU: Force reinterpret off without copy image.

Also, assert we have it when using it, since there's ifs.

* Add some checks trying to prevent creation of 0 sized textures.

Saw a crash log with a driver crash in CreateTexture...

* Update lang submodule

* Io: Truncate reads/writes to valid memory.

A PSP might crash in these cases, but it's better if we avoid a crash.

* Don't assert on invalid format in CwCheat.

Not sure exactly what we should do, though..

* Build: Allow on actions test branch.

* Build: Cache Qt during Actions run.

* Android: Ensure shutdown waits for render.

We apparently have a case where render is busy during shutdown, based on
crash reports.

Co-authored-by: Henrik Rydgård <[email protected]>
Co-authored-by: Unknown W. Brackets <[email protected]>
Co-authored-by: nassau-tk <[email protected]>
Co-authored-by: sum2012 <[email protected]>
Co-authored-by: ANR2ME <[email protected]>
Co-authored-by: AdamN <[email protected]>
Co-authored-by: Florin9doi <[email protected]>
Co-authored-by: Gleb Mazovetskiy <[email protected]>
Co-authored-by: jdgleaver <[email protected]>
Co-authored-by: Anuskuss <[email protected]>
  • Loading branch information
11 people authored Feb 14, 2021
1 parent 5bdf949 commit 5020159
Show file tree
Hide file tree
Showing 143 changed files with 2,207 additions and 588 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- master
# For testing.
- actions
paths-ignore:
- '*.{txt,md}'
- 'Tools/**'
Expand Down Expand Up @@ -176,9 +178,19 @@ jobs:
with:
submodules: recursive

- name: Cache Qt
uses: actions/cache@v1
if: matrix.extra == 'qt'
id: cache-qt
with:
path: ${{ runner.workspace }}/Qt
key: ${{ runner.os }}-QtCache

- name: Install Qt
uses: jurplel/install-qt-action@v2
if: matrix.extra == 'qt'
with:
cached: ${{ steps.cache-qt.outputs.cache-hit }}

- uses: nttld/setup-ndk@v1
if: matrix.extra == 'android'
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,3 @@ debian/ppsspp/

# RenderDoc
*.rdc

# bad output from libretro. don't want to accidentally add it
nul
33 changes: 28 additions & 5 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,49 @@ variables:
variables:
EXTRA_PATH: lib

.windows-defs:
variables:
MAKEFILE_PATH: libretro

include:
- template: Jobs/Code-Quality.gitlab-ci.yml
- project: 'libretro-infrastructure/ci-templates'
file: '/android-cmake.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/linux-cmake.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/windows-x64-msvc19-msys2.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/windows-i686-msvc19-msys2.yml'

stages:
- build-prepare
- build-shared
- build-static
- test

#Desktop
libretro-build-linux-x86_64:
# Desktop
libretro-build-linux-x64:
extends:
- .libretro-linux-cmake-x86_64
- .core-defs
- .linux-defs

libretro-build-linux-i686:
extends:
- .libretro-linux-cmake-x86
- .core-defs
- .linux-defs

libretro-build-windows-x64:
extends:
- .libretro-windows-x64-msvc19-msys2-make-default
- .core-defs
- .windows-defs

libretro-build-windows-i686:
extends:
- .libretro-windows-i686-msvc19-msys2-make-default
- .core-defs
- .windows-defs

# Android
libretro-build-android-armeabi-v7a:
extends:
Expand Down
27 changes: 23 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ option(USE_MINIUPNPC "Build with miniUPnPc support" ON)
option(USE_SYSTEM_SNAPPY "Dynamically link against system snappy" ${USE_SYSTEM_SNAPPY})
option(USE_SYSTEM_FFMPEG "Dynamically link against system FFMPEG" ${USE_SYSTEM_FFMPEG})
option(USE_SYSTEM_LIBZIP "Dynamically link against system libzip" ${USE_SYSTEM_LIBZIP})
option(USE_ADDRESS_SANITIZER "Use Clang memory sanitizer" ${USE_ADDRESS_SANITIZER})
option(USE_ASAN "Use address sanitizer" OFF)
option(USE_UBSAN "Use undefined behaviour sanitizer" OFF)

if(UNIX AND NOT (APPLE OR ANDROID) AND VULKAN)
if(USING_X11_VULKAN)
Expand Down Expand Up @@ -272,11 +273,24 @@ if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch -Wno-uninitialized")
endif()

if(USE_ADDRESS_SANITIZER)
if(USE_ASAN)
message("Address sanitizer enabled (DEBUG only)")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -fsanitize=address")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fsanitize=address")
add_definitions(-DUSE_ADDRESS_SANITIZER)
add_definitions(-DUSE_ASAN)
endif()
if(USE_UBSAN)
message("Undefined behaviour sanitizer enabled (DEBUG only)")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fsanitize=undefined")

# UBSAN is a collection of sanitizers, including vtpr, which reqiuires RTTI.
# ext/glslang disables RTTI by default using the `ENABLE_RTTI` option.
# If RTTI is disabled, we must also disable the vtpr sanitizer.
if(NOT ENABLE_RTTI)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-sanitize=vptr")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-sanitize=vptr")
endif()
endif()

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -D_DEBUG")
Expand Down Expand Up @@ -1492,6 +1506,10 @@ add_library(${CoreLibName} ${CoreLinkType}
Core/Debugger/WebSocket/GPURecordSubscriber.h
Core/Debugger/WebSocket/HLESubscriber.cpp
Core/Debugger/WebSocket/HLESubscriber.h
Core/Debugger/WebSocket/InputBroadcaster.cpp
Core/Debugger/WebSocket/InputBroadcaster.h
Core/Debugger/WebSocket/InputSubscriber.cpp
Core/Debugger/WebSocket/InputSubscriber.h
Core/Debugger/WebSocket/LogBroadcaster.cpp
Core/Debugger/WebSocket/LogBroadcaster.h
Core/Debugger/WebSocket/MemorySubscriber.cpp
Expand Down Expand Up @@ -2186,6 +2204,7 @@ if(IOS)
RESOURCE "ios/Settings.bundle"
RESOURCE "MoltenVK/iOS/Frameworks"
XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET}
XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "iPhone/iPad"
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES
XCODE_ATTRIBUTE_ENABLE_BITCODE NO
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-"
Expand Down
3 changes: 0 additions & 3 deletions Common/GPU/OpenGL/GLCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
#elif defined(USING_GLES2)
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
// At least Nokia platforms need the three below
#include <KHR/khrplatform.h>
typedef char GLchar;
#define GL_BGRA_EXT 0x80E1
#else // OpenGL
#include "GL/glew.h"
Expand Down
4 changes: 3 additions & 1 deletion Common/GPU/OpenGL/GLFeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void CheckGLExtensions() {
// Just for reference: Galaxy Y has renderer == "VideoCore IV HW"
} else if (vendor == "Vivante Corporation") {
gl_extensions.gpuVendor = GPU_VENDOR_VIVANTE;
} else if (vendor == "Apple Inc.") {
} else if (vendor == "Apple Inc." || vendor == "Apple") {
gl_extensions.gpuVendor = GPU_VENDOR_APPLE;
} else {
WARN_LOG(G3D, "Unknown GL vendor: '%s'", vendor.c_str());
Expand Down Expand Up @@ -594,6 +594,8 @@ std::string ApplyGLSLPrelude(const std::string &source, uint32_t stage) {
if (!gl_extensions.IsGLES && gl_extensions.IsCoreContext) {
// We need to add a corresponding #version. Apple drivers fail without an exact match.
version = StringFromFormat("#version %d\n", gl_extensions.GLSLVersion());
} else if (gl_extensions.IsGLES && gl_extensions.GLES3) {
version = StringFromFormat("#version %d es\n", gl_extensions.GLSLVersion());
}
if (stage == GL_FRAGMENT_SHADER) {
temp = version + glsl_fragment_prelude + source;
Expand Down
2 changes: 2 additions & 0 deletions Common/GPU/OpenGL/GLQueueRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1369,12 +1369,14 @@ void GLQueueRunner::PerformCopy(const GLRStep &step) {

#if defined(USING_GLES2)
#ifndef IOS
_assert_msg_(gl_extensions.OES_copy_image || gl_extensions.NV_copy_image || gl_extensions.EXT_copy_image, "Image copy extension expected");
glCopyImageSubDataOES(
srcTex, target, srcLevel, srcRect.x, srcRect.y, srcZ,
dstTex, target, dstLevel, dstPos.x, dstPos.y, dstZ,
srcRect.w, srcRect.h, depth);
#endif
#else
_assert_msg_(gl_extensions.ARB_copy_image || gl_extensions.NV_copy_image, "Image copy extension expected");
if (gl_extensions.ARB_copy_image) {
glCopyImageSubData(
srcTex, target, srcLevel, srcRect.x, srcRect.y, srcZ,
Expand Down
6 changes: 3 additions & 3 deletions Common/GPU/OpenGL/thin3d_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class OpenGLPipeline : public Pipeline {

// TODO: Optimize by getting the locations first and putting in a custom struct
UniformBufferDesc dynamicUniforms;
GLint samplerLocs_[8];
GLint samplerLocs_[8]{};
std::vector<GLint> dynamicUniformLocs_;
GLRProgram *program_ = nullptr;

Expand Down Expand Up @@ -1038,8 +1038,8 @@ Pipeline *OpenGLContext::CreateGraphicsPipeline(const PipelineDesc &desc) {
ERROR_LOG(G3D, "Pipeline requires at least one shader");
return nullptr;
}
if ((int)desc.prim >= (int)Primitive::PRIMITIVE_TYPE_COUNT) {
ERROR_LOG(G3D, "Invalid primitive type");
if ((uint32_t)desc.prim >= (uint32_t)Primitive::PRIMITIVE_TYPE_COUNT) {
ERROR_LOG(G3D, "Invalid primitive type");
return nullptr;
}
if (!desc.depthStencil || !desc.blend || !desc.raster) {
Expand Down
5 changes: 5 additions & 0 deletions Common/GPU/Vulkan/VulkanDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ VKAPI_ATTR VkBool32 VKAPI_CALL VulkanDebugUtilsCallback(
// UNASSIGNED-CoreValidation-Shader-OutputNotConsumed - benign perf warning
return false;
}
if (messageCode == 1303270965) {
// Benign perf warning, image blit using GENERAL layout.
// UNASSIGNED
return false;
}

const char *pLayerPrefix = "";
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) {
Expand Down
20 changes: 15 additions & 5 deletions Common/GPU/Vulkan/VulkanImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ static bool IsDepthStencilFormat(VkFormat format) {
}

bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, VulkanDeviceAllocator *allocator, int w, int h, int numMips, VkFormat format, VkImageLayout initialLayout, VkImageUsageFlags usage, const VkComponentMapping *mapping) {
if (w == 0 || h == 0 || numMips == 0) {
ERROR_LOG(G3D, "Can't create a zero-size VulkanTexture");
return false;
}

Wipe();

width_ = w;
Expand Down Expand Up @@ -196,7 +201,8 @@ void VulkanTexture::ClearMip(VkCommandBuffer cmd, int mip, uint32_t value) {
vkCmdClearColorImage(cmd, image_, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clearVal, 1, &range);
}

void VulkanTexture::GenerateMip(VkCommandBuffer cmd, int mip) {
// Low-quality mipmap generation by bilinear blit, but works okay.
void VulkanTexture::GenerateMip(VkCommandBuffer cmd, int mip, VkImageLayout imageLayout) {
_assert_msg_(mip != 0, "Cannot generate the first level");
_assert_msg_(mip < numMips_, "Cannot generate mipmaps past the maximum created (%d vs %d)", mip, numMips_);
VkImageBlit blit{};
Expand All @@ -214,16 +220,20 @@ void VulkanTexture::GenerateMip(VkCommandBuffer cmd, int mip) {
blit.dstOffsets[1].y = height_ >> mip;
blit.dstOffsets[1].z = 1;

// TODO: We could do better with the image transitions - would be enough with one per level
// for the memory barrier, then one final one for the whole stack when done. This function
// currently doesn't have a global enough view, though.
// We should also coalesce barriers across multiple texture uploads in a frame and all kinds of other stuff, but...

TransitionImageLayout2(cmd, image_, mip - 1, 1, VK_IMAGE_ASPECT_COLOR_BIT,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
imageLayout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT);

// Low-quality mipmap generation, but works okay.
vkCmdBlitImage(cmd, image_, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, image_, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &blit, VK_FILTER_LINEAR);
vkCmdBlitImage(cmd, image_, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, image_, imageLayout, 1, &blit, VK_FILTER_LINEAR);

TransitionImageLayout2(cmd, image_, mip - 1, 1, VK_IMAGE_ASPECT_COLOR_BIT,
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, imageLayout,
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
VK_ACCESS_TRANSFER_READ_BIT, VK_ACCESS_TRANSFER_WRITE_BIT);
}
Expand Down
2 changes: 1 addition & 1 deletion Common/GPU/Vulkan/VulkanImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class VulkanTexture {
bool CreateDirect(VkCommandBuffer cmd, VulkanDeviceAllocator *allocator, int w, int h, int numMips, VkFormat format, VkImageLayout initialLayout, VkImageUsageFlags usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT, const VkComponentMapping *mapping = nullptr);
void ClearMip(VkCommandBuffer cmd, int mip, uint32_t value);
void UploadMip(VkCommandBuffer cmd, int mip, int mipWidth, int mipHeight, VkBuffer buffer, uint32_t offset, size_t rowLength); // rowLength is in pixels
void GenerateMip(VkCommandBuffer cmd, int mip);
void GenerateMip(VkCommandBuffer cmd, int mip, VkImageLayout imageLayout);
void EndCreate(VkCommandBuffer cmd, bool vertexTexture = false, VkImageLayout layout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);

// When loading mips from compute shaders, you need to pass VK_IMAGE_LAYOUT_GENERAL to the above function.
Expand Down
7 changes: 4 additions & 3 deletions Common/GPU/Vulkan/thin3d_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ bool VKShaderModule::Compile(VulkanContext *vulkan, ShaderLanguage language, con
std::vector<uint32_t> spirv;
std::string errorMessage;
if (!GLSLtoSPV(vkstage_, source_.c_str(), GLSLVariant::VULKAN, spirv, &errorMessage)) {
INFO_LOG(G3D, "Shader compile to module failed: %s", errorMessage.c_str());
WARN_LOG(G3D, "Shader compile to module failed: %s", errorMessage.c_str());
return false;
}

Expand All @@ -231,6 +231,7 @@ bool VKShaderModule::Compile(VulkanContext *vulkan, ShaderLanguage language, con
if (vulkan->CreateShaderModule(spirv, &module_)) {
ok_ = true;
} else {
WARN_LOG(G3D, "vkCreateShaderModule failed");
ok_ = false;
}
return ok_;
Expand Down Expand Up @@ -754,7 +755,7 @@ bool VKTexture::Create(VkCommandBuffer cmd, VulkanPushBuffer *push, const Textur
}
// Generate the rest of the mips automatically.
for (; i < mipLevels_; i++) {
vkTex_->GenerateMip(cmd, i);
vkTex_->GenerateMip(cmd, i, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
}
}
vkTex_->EndCreate(cmd, false);
Expand Down Expand Up @@ -1281,7 +1282,7 @@ ShaderModule *VKContext::CreateShaderModule(ShaderStage stage, ShaderLanguage la
if (shader->Compile(vulkan_, language, data, size)) {
return shader;
} else {
ERROR_LOG(G3D, "Failed to compile shader: %s", (const char *)data);
ERROR_LOG(G3D, "Failed to compile shader:\n%s", (const char *)data);
shader->Release();
return nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion Common/MemArenaPosix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void MemArena::ReleaseView(void* view, size_t size) {

u8* MemArena::Find4GBBase() {
// Now, create views in high memory where there's plenty of space.
#if PPSSPP_ARCH(64BIT) && !defined(USE_ADDRESS_SANITIZER)
#if PPSSPP_ARCH(64BIT) && !defined(USE_ASAN)
// We should probably just go look in /proc/self/maps for some free space.
// But let's try the anonymous mmap trick, just like on 32-bit, but bigger and
// aligned to 4GB for the movk trick. We can ensure that we get an aligned 4GB
Expand Down
26 changes: 26 additions & 0 deletions Common/Render/DrawBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,20 @@ void DrawBuffer::DrawImage(ImageID atlas_image, float x, float y, float scale, C
DrawImageStretch(atlas_image, x, y, x + w, y + h, color);
}

void DrawBuffer::DrawImageCenterTexel(ImageID atlas_image, float x1, float y1, float x2, float y2, Color color) {
const AtlasImage *image = atlas->getImage(atlas_image);
if (!image)
return;
float centerU = (image->u1 + image->u2) * 0.5f;
float centerV = (image->v1 + image->v2) * 0.5f;
V(x1, y1, color, centerU, centerV);
V(x2, y1, color, centerU, centerV);
V(x2, y2, color, centerU, centerV);
V(x1, y1, color, centerU, centerV);
V(x2, y2, color, centerU, centerV);
V(x1, y2, color, centerU, centerV);
}

void DrawBuffer::DrawImageStretch(ImageID atlas_image, float x1, float y1, float x2, float y2, Color color) {
const AtlasImage *image = atlas->getImage(atlas_image);
if (!image)
Expand All @@ -236,6 +250,18 @@ void DrawBuffer::DrawImageStretch(ImageID atlas_image, float x1, float y1, float
V(x1, y2, color, image->u1, image->v2);
}

void DrawBuffer::DrawImageStretchVGradient(ImageID atlas_image, float x1, float y1, float x2, float y2, Color color1, Color color2) {
const AtlasImage *image = atlas->getImage(atlas_image);
if (!image)
return;
V(x1, y1, color1, image->u1, image->v1);
V(x2, y1, color1, image->u2, image->v1);
V(x2, y2, color2, image->u2, image->v2);
V(x1, y1, color1, image->u1, image->v1);
V(x2, y2, color2, image->u2, image->v2);
V(x1, y2, color2, image->u1, image->v2);
}

inline void rot(float *v, float angle, float xc, float yc) {
const float x = v[0] - xc;
const float y = v[1] - yc;
Expand Down
4 changes: 4 additions & 0 deletions Common/Render/DrawBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ class DrawBuffer {
const Atlas *GetAtlas() const { return atlas; }
bool MeasureImage(ImageID atlas_image, float *w, float *h);
void DrawImage(ImageID atlas_image, float x, float y, float scale, Color color = COLOR(0xFFFFFF), int align = ALIGN_TOPLEFT);

// Good for stretching out a white image without edge artifacts that I'm getting on iOS.
void DrawImageCenterTexel(ImageID atlas_image, float x1, float y1, float x2, float y2, Color color = COLOR(0xFFFFFF));
void DrawImageStretch(ImageID atlas_image, float x1, float y1, float x2, float y2, Color color = COLOR(0xFFFFFF));
void DrawImageStretchVGradient(ImageID atlas_image, float x1, float y1, float x2, float y2, Color color1, Color color2);
void DrawImageStretch(ImageID atlas_image, const Bounds &bounds, Color color = COLOR(0xFFFFFF)) {
DrawImageStretch(atlas_image, bounds.x, bounds.y, bounds.x2(), bounds.y2(), color);
}
Expand Down
2 changes: 1 addition & 1 deletion Common/Serialize/Serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void PointerWrap::DoMarker(const char *prevName, u32 arbitraryNumber) {
u32 cookie = arbitraryNumber;
Do(*this, cookie);
if (mode == PointerWrap::MODE_READ && cookie != arbitraryNumber) {
_assert_msg_(false, "Error: After \"%s\", found %d (0x%X) instead of save marker %d (0x%X). Aborting savestate load...", prevName, cookie, cookie, arbitraryNumber, arbitraryNumber);
ERROR_LOG(SAVESTATE, "Error: After \"%s\", found %d (0x%X) instead of save marker %d (0x%X). Aborting savestate load...", prevName, cookie, cookie, arbitraryNumber, arbitraryNumber);
SetError(ERROR_FAILURE);
}
}
Expand Down
Loading

0 comments on commit 5020159

Please sign in to comment.