options: anisotropic filtering, oit pixel buffer size, fast gdrom load

This commit is contained in:
flyinghead 2021-07-06 16:19:12 +02:00
parent a3b66aec1f
commit c205a888a9
16 changed files with 60 additions and 29 deletions

View File

@ -16,6 +16,7 @@ jobs:
- {name: x86_64-pc-windows-msvc, os: windows-latest, cmakeArgs: -DCMAKE_SYSTEM_VERSION="10.0.18362.0" -G "Visual Studio 16 2019" -A x64} - {name: x86_64-pc-windows-msvc, os: windows-latest, cmakeArgs: -DCMAKE_SYSTEM_VERSION="10.0.18362.0" -G "Visual Studio 16 2019" -A x64}
- {name: x86_64-w64-mingw32, os: windows-latest, cmakeArgs: -G "MinGW Makefiles", destDir: win} - {name: x86_64-w64-mingw32, os: windows-latest, cmakeArgs: -G "MinGW Makefiles", destDir: win}
- {name: libretro-x86_64-pc-linux-gnu, os: ubuntu-latest, cmakeArgs: -DLIBRETRO=ON -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -DUSE_VULKAN=OFF} - {name: libretro-x86_64-pc-linux-gnu, os: ubuntu-latest, cmakeArgs: -DLIBRETRO=ON -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -DUSE_VULKAN=OFF}
- {name: libretro-x86_64-w64-mingw32, os: windows-latest, cmakeArgs: -DLIBRETRO=ON -DUSE_VULKAN=OFF -G "MinGW Makefiles"}
steps: steps:
- name: Set up build environment (macos-latest) - name: Set up build environment (macos-latest)
@ -34,7 +35,7 @@ jobs:
- name: Set up build environment (windows-latest) - name: Set up build environment (windows-latest)
run: echo "DXSDK_DIR=${Env:HOMEDRIVE}${Env:HOMEPATH}\ccache\" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append run: echo "DXSDK_DIR=${Env:HOMEDRIVE}${Env:HOMEPATH}\ccache\" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
if: matrix.config.os == 'windows-latest' && matrix.config.name != 'x86_64-w64-mingw32' if: matrix.config.os == 'windows-latest' && matrix.config.name != 'x86_64-w64-mingw32' && matrix.config.name != 'libretro-x86_64-w64-mingw32'
- uses: actions/cache@v2 - uses: actions/cache@v2
with: with:
@ -52,7 +53,7 @@ jobs:
if: matrix.config.os == 'windows-latest' if: matrix.config.os == 'windows-latest'
- name: Download DX2010 - name: Download DX2010
if: steps.cache.outputs.cache-hit != 'true' && matrix.config.os == 'windows-latest' && matrix.config.name != 'x86_64-w64-mingw32' if: steps.cache.outputs.cache-hit != 'true' && matrix.config.os == 'windows-latest' && matrix.config.name != 'x86_64-w64-mingw32' && matrix.config.name != 'libretro-x86_64-w64-mingw32'
run: | run: |
curl -L https://download.microsoft.com/download/a/e/7/ae743f1f-632b-4809-87a9-aa1bb3458e31/DXSDK_Jun10.exe -o _DX2010_.exe curl -L https://download.microsoft.com/download/a/e/7/ae743f1f-632b-4809-87a9-aa1bb3458e31/DXSDK_Jun10.exe -o _DX2010_.exe
7z x _DX2010_.exe DXSDK/Include -o_DX2010_ 7z x _DX2010_.exe DXSDK/Include -o_DX2010_

View File

@ -879,10 +879,11 @@ if(USE_VULKAN AND NOT APPLE)
endif() endif()
endif() endif()
# TODO
if(WIN32 AND NOT LIBRETRO) if(WIN32 AND NOT LIBRETRO)
target_sources(${PROJECT_NAME} PRIVATE target_sources(${PROJECT_NAME} PRIVATE
core/rend/dx9/comptr.h core/rend/dx9/comptr.h
core/rend/dx9/d3d_overlay.h
core/rend/dx9/d3d_overlay.cpp
core/rend/dx9/d3d_renderer.h core/rend/dx9/d3d_renderer.h
core/rend/dx9/d3d_renderer.cpp core/rend/dx9/d3d_renderer.cpp
core/rend/dx9/d3d_shaders.h core/rend/dx9/d3d_shaders.h
@ -890,11 +891,7 @@ if(WIN32 AND NOT LIBRETRO)
core/rend/dx9/d3d_texture.h core/rend/dx9/d3d_texture.h
core/rend/dx9/d3d_texture.cpp core/rend/dx9/d3d_texture.cpp
core/rend/dx9/dxcontext.h core/rend/dx9/dxcontext.h
core/rend/dx9/dxcontext.cpp) core/rend/dx9/dxcontext.cpp
if(NOT LIBRETRO)
target_sources(${PROJECT_NAME} PRIVATE
core/rend/dx9/d3d_overlay.h
core/rend/dx9/d3d_overlay.cpp
core/rend/dx9/imgui_impl_dx9.h core/rend/dx9/imgui_impl_dx9.h
core/rend/dx9/imgui_impl_dx9.cpp) core/rend/dx9/imgui_impl_dx9.cpp)
if(NOT MINGW) if(NOT MINGW)
@ -905,7 +902,6 @@ if(WIN32 AND NOT LIBRETRO)
target_link_directories(${PROJECT_NAME} PRIVATE "$ENV{DXSDK_DIR}/Lib/x86") target_link_directories(${PROJECT_NAME} PRIVATE "$ENV{DXSDK_DIR}/Lib/x86")
endif() endif()
endif() endif()
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE d3d9 d3dx9) target_link_libraries(${PROJECT_NAME} PRIVATE d3d9 d3dx9)
endif() endif()

View File

@ -90,12 +90,15 @@ Option<int> MaxThreads("pvr.MaxThreads", 3);
Option<int> AutoSkipFrame("pvr.AutoSkipFrame", 0); Option<int> AutoSkipFrame("pvr.AutoSkipFrame", 0);
Option<int> RenderResolution("rend.Resolution", 480); Option<int> RenderResolution("rend.Resolution", 480);
Option<bool> VSync("rend.vsync", true); Option<bool> VSync("rend.vsync", true);
Option<u64> PixelBufferSize("rend.PixelBufferSize", 512 * 1024 * 1024);
Option<int> AnisotropicFiltering("rend.AnisotropicFiltering", 1);
// Misc // Misc
Option<bool> SerialConsole("Debug.SerialConsoleEnabled"); Option<bool> SerialConsole("Debug.SerialConsoleEnabled");
Option<bool> SerialPTY("Debug.SerialPTY"); Option<bool> SerialPTY("Debug.SerialPTY");
Option<bool> UseReios("UseReios"); Option<bool> UseReios("UseReios");
Option<bool> FastGDRomLoad("FastGDRomLoad", false);
Option<bool> OpenGlChecks("OpenGlChecks", false, "validate"); Option<bool> OpenGlChecks("OpenGlChecks", false, "validate");

View File

@ -389,12 +389,15 @@ extern Option<int> MaxThreads;
extern Option<int> AutoSkipFrame; // 0: none, 1: some, 2: more extern Option<int> AutoSkipFrame; // 0: none, 1: some, 2: more
extern Option<int> RenderResolution; extern Option<int> RenderResolution;
extern Option<bool> VSync; extern Option<bool> VSync;
extern Option<u64> PixelBufferSize;
extern Option<int> AnisotropicFiltering;
// Misc // Misc
extern Option<bool> SerialConsole; extern Option<bool> SerialConsole;
extern Option<bool> SerialPTY; extern Option<bool> SerialPTY;
extern Option<bool> UseReios; extern Option<bool> UseReios;
extern Option<bool> FastGDRomLoad;
extern Option<bool> OpenGlChecks; extern Option<bool> OpenGlChecks;

View File

@ -1049,6 +1049,8 @@ static int getGDROMTicks()
{ {
if (SB_GDST & 1) if (SB_GDST & 1)
{ {
if (config::FastGDRomLoad)
return 512;
u32 len = SB_GDLEN == 0 ? 0x02000000 : SB_GDLEN; u32 len = SB_GDLEN == 0 ? 0x02000000 : SB_GDLEN;
if (len - SB_GDLEND > 10240) if (len - SB_GDLEND > 10240)
return 1000000; // Large transfers: GD-ROM transfer rate 1.8 MB/s return 1000000; // Large transfers: GD-ROM transfer rate 1.8 MB/s

View File

@ -74,7 +74,7 @@ static void read_sectors_to(u32 addr, u32 sector, u32 count)
gd_hle_state.cur_sector = sector + count - 1; gd_hle_state.cur_sector = sector + count - 1;
if (virtual_addr) if (virtual_addr)
gd_hle_state.xfer_end_time = 0; gd_hle_state.xfer_end_time = 0;
else if (count > 5) else if (count > 5 && !config::FastGDRomLoad)
// Large Transfers: GD-ROM rate (approx. 1.8 MB/s) // Large Transfers: GD-ROM rate (approx. 1.8 MB/s)
gd_hle_state.xfer_end_time = sh4_sched_now64() + (u64)count * 2048 * 1000000L / 10240; gd_hle_state.xfer_end_time = sh4_sched_now64() + (u64)count * 2048 * 1000000L / 10240;
else else

View File

@ -29,8 +29,6 @@ static GLuint g_quadBuffer;
static GLuint g_quadIndexBuffer; static GLuint g_quadIndexBuffer;
static GLuint g_quadVertexArray; static GLuint g_quadVertexArray;
static GLuint pixel_buffer_size = 512 * 1024 * 1024; // Initial size 512 MB
#define MAX_PIXELS_PER_FRAGMENT "32" #define MAX_PIXELS_PER_FRAGMENT "32"
static const char *final_shader_source = SHADER_HEADER static const char *final_shader_source = SHADER_HEADER
@ -277,7 +275,7 @@ void initABuffer()
// get the max buffer size // get the max buffer size
GLint64 size; GLint64 size;
glGetInteger64v(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, &size); glGetInteger64v(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, &size);
pixel_buffer_size = (GLuint)std::min((GLint64)pixel_buffer_size, size); GLsizeiptr pixel_buffer_size = std::min<GLsizeiptr>((u64)config::PixelBufferSize, size);
// Create the buffer // Create the buffer
glGenBuffers(1, &pixels_buffer); glGenBuffers(1, &pixels_buffer);

View File

@ -226,6 +226,14 @@ static void SetGPState(const PolyParam* gp)
glSamplerParameteri(texSamplers[i], GL_TEXTURE_MAG_FILTER, GL_LINEAR); glSamplerParameteri(texSamplers[i], GL_TEXTURE_MAG_FILTER, GL_LINEAR);
if (mipmapped) if (mipmapped)
glSamplerParameterf(texSamplers[i], GL_TEXTURE_LOD_BIAS, D_Adjust_LoD_Bias[tsp.MipMapD]); glSamplerParameterf(texSamplers[i], GL_TEXTURE_LOD_BIAS, D_Adjust_LoD_Bias[tsp.MipMapD]);
if (gl.max_anisotropy > 1.f)
{
if (config::AnisotropicFiltering > 1)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY,
std::min<float>(config::AnisotropicFiltering, gl.max_anisotropy));
else
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY, 1.f);
}
} }
} }
} }

View File

@ -194,6 +194,19 @@ __forceinline
if (!gl.is_gles && gl.gl_major >= 3 && mipmapped) if (!gl.is_gles && gl.gl_major >= 3 && mipmapped)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, D_Adjust_LoD_Bias[gp->tsp.MipMapD]); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, D_Adjust_LoD_Bias[gp->tsp.MipMapD]);
#endif #endif
if (gl.max_anisotropy > 1.f)
{
if (config::AnisotropicFiltering > 1)
{
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY,
std::min<float>(config::AnisotropicFiltering, gl.max_anisotropy));
// Set the recommended minification filter for best results
if (mipmapped)
glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
}
else
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY, 1.f);
}
} }
} }

View File

@ -466,7 +466,7 @@ void findGLVersion()
gl.highp_float_supported = true; gl.highp_float_supported = true;
} }
gl.max_anisotropy = 1.f; gl.max_anisotropy = 1.f;
#if !defined(GLES2) && defined(GL_MAX_TEXTURE_MAX_ANISOTROPY) #if !defined(GLES2)
if (gl.gl_major >= 3) if (gl.gl_major >= 3)
{ {
for (u32 i = 0; ; i++) for (u32 i = 0; ; i++)

View File

@ -8,6 +8,13 @@
#include <unordered_map> #include <unordered_map>
#include <glm/glm.hpp> #include <glm/glm.hpp>
#ifndef GL_TEXTURE_MAX_ANISOTROPY
#define GL_TEXTURE_MAX_ANISOTROPY 0x84FE
#endif
#ifndef GL_MAX_TEXTURE_MAX_ANISOTROPY
#define GL_MAX_TEXTURE_MAX_ANISOTROPY 0x84FF
#endif
#define glCheck() do { if (unlikely(config::OpenGlChecks)) { verify(glGetError()==GL_NO_ERROR); } } while(0) #define glCheck() do { if (unlikely(config::OpenGlChecks)) { verify(glGetError()==GL_NO_ERROR); } } while(0)
#define VERTEX_POS_ARRAY 0 #define VERTEX_POS_ARRAY 0

View File

@ -24,8 +24,6 @@
#include <memory> #include <memory>
const vk::DeviceSize PixelBufferSize = 512 * 1024 * 1024;
class OITBuffers class OITBuffers
{ {
public: public:
@ -51,7 +49,7 @@ public:
if (!pixelBuffer) if (!pixelBuffer)
{ {
pixelBuffer = std::unique_ptr<BufferData>(new BufferData(std::min(PixelBufferSize, context->GetMaxMemoryAllocationSize()), pixelBuffer = std::unique_ptr<BufferData>(new BufferData(std::min<vk::DeviceSize>(config::PixelBufferSize, context->GetMaxMemoryAllocationSize()),
vk::BufferUsageFlagBits::eStorageBuffer, vk::MemoryPropertyFlagBits::eDeviceLocal)); vk::BufferUsageFlagBits::eStorageBuffer, vk::MemoryPropertyFlagBits::eDeviceLocal));
} }
if (!pixelCounter) if (!pixelCounter)

View File

@ -91,11 +91,13 @@ public:
vk::SamplerAddressMode vRepeat = tsp.ClampV ? vk::SamplerAddressMode::eClampToEdge vk::SamplerAddressMode vRepeat = tsp.ClampV ? vk::SamplerAddressMode::eClampToEdge
: tsp.FlipV ? vk::SamplerAddressMode::eMirroredRepeat : vk::SamplerAddressMode::eRepeat; : tsp.FlipV ? vk::SamplerAddressMode::eMirroredRepeat : vk::SamplerAddressMode::eRepeat;
bool anisotropicFiltering = config::AnisotropicFiltering > 1 && VulkanContext::Instance()->SupportsSamplerAnisotropy()
&& filter == vk::Filter::eLinear;
return samplers.emplace( return samplers.emplace(
std::make_pair(samplerHash, VulkanContext::Instance()->GetDevice().createSamplerUnique( std::make_pair(samplerHash, VulkanContext::Instance()->GetDevice().createSamplerUnique(
vk::SamplerCreateInfo(vk::SamplerCreateFlags(), filter, filter, vk::SamplerCreateInfo(vk::SamplerCreateFlags(), filter, filter,
vk::SamplerMipmapMode::eNearest, uRepeat, vRepeat, vk::SamplerAddressMode::eClampToEdge, D_Adjust_LoD_Bias[tsp.MipMapD], vk::SamplerMipmapMode::eNearest, uRepeat, vRepeat, vk::SamplerAddressMode::eClampToEdge, D_Adjust_LoD_Bias[tsp.MipMapD],
VulkanContext::Instance()->SupportsSamplerAnisotropy() && filter == vk::Filter::eLinear, 4.0f, anisotropicFiltering, std::min<float>(config::AnisotropicFiltering, VulkanContext::Instance()->GetMaxSamplerAnisotropy()),
false, vk::CompareOp::eNever, false, vk::CompareOp::eNever,
0.0f, 256.0f, vk::BorderColor::eFloatOpaqueBlack)))).first->second.get(); 0.0f, 256.0f, vk::BorderColor::eFloatOpaqueBlack)))).first->second.get();
} }

View File

@ -222,6 +222,7 @@ bool VulkanContext::InitInstance(const char** extensions, uint32_t extensions_co
uniformBufferAlignment = properties->limits.minUniformBufferOffsetAlignment; uniformBufferAlignment = properties->limits.minUniformBufferOffsetAlignment;
storageBufferAlignment = properties->limits.minStorageBufferOffsetAlignment; storageBufferAlignment = properties->limits.minStorageBufferOffsetAlignment;
maxStorageBufferRange = properties->limits.maxStorageBufferRange; maxStorageBufferRange = properties->limits.maxStorageBufferRange;
maxSamplerAnisotropy = properties->limits.maxSamplerAnisotropy;
unifiedMemory = properties->deviceType == vk::PhysicalDeviceType::eIntegratedGpu; unifiedMemory = properties->deviceType == vk::PhysicalDeviceType::eIntegratedGpu;
vendorID = properties->vendorID; vendorID = properties->vendorID;
NOTICE_LOG(RENDERER, "Vulkan API %s. Device %s", vulkan11 ? "1.1" : "1.0", properties->deviceName); NOTICE_LOG(RENDERER, "Vulkan API %s. Device %s", vulkan11 ? "1.1" : "1.0", properties->deviceName);

View File

@ -98,6 +98,7 @@ public:
static VulkanContext *Instance() { return contextInstance; } static VulkanContext *Instance() { return contextInstance; }
bool SupportsFragmentShaderStoresAndAtomics() const { return fragmentStoresAndAtomics; } bool SupportsFragmentShaderStoresAndAtomics() const { return fragmentStoresAndAtomics; }
bool SupportsSamplerAnisotropy() const { return samplerAnisotropy; } bool SupportsSamplerAnisotropy() const { return samplerAnisotropy; }
float GetMaxSamplerAnisotropy() const { return samplerAnisotropy ? maxSamplerAnisotropy : 1.f; }
bool SupportsDedicatedAllocation() const { return dedicatedAllocationSupported; } bool SupportsDedicatedAllocation() const { return dedicatedAllocationSupported; }
const VMAllocator& GetAllocator() const { return allocator; } const VMAllocator& GetAllocator() const { return allocator; }
bool IsUnifiedMemory() const { return unifiedMemory; } bool IsUnifiedMemory() const { return unifiedMemory; }
@ -159,6 +160,7 @@ private:
bool optimalTilingSupported4444 = false; bool optimalTilingSupported4444 = false;
bool fragmentStoresAndAtomics = false; bool fragmentStoresAndAtomics = false;
bool samplerAnisotropy = false; bool samplerAnisotropy = false;
float maxSamplerAnisotropy = 0.f;
bool dedicatedAllocationSupported = false; bool dedicatedAllocationSupported = false;
bool unifiedMemory = false; bool unifiedMemory = false;
u32 vendorID = 0; u32 vendorID = 0;

View File

@ -189,8 +189,5 @@ protected:
// TODO // TODO
extern Option<bool> ThreadedRendering; extern Option<bool> ThreadedRendering;
extern Option<int> AnisotropicFiltering;
extern Option<bool> UpdateMode; extern Option<bool> UpdateMode;
extern Option<bool> PowerVR2Filter; extern Option<bool> PowerVR2Filter;
extern Option<u64> PixelBufferSize;
extern Option<bool> FastGDRomLoad;