diff --git a/Source/Core/VideoBackends/Null/CMakeLists.txt b/Source/Core/VideoBackends/Null/CMakeLists.txt index f186da0067..6e0b7aa46b 100644 --- a/Source/Core/VideoBackends/Null/CMakeLists.txt +++ b/Source/Core/VideoBackends/Null/CMakeLists.txt @@ -2,7 +2,6 @@ set(SRCS NullBackend.cpp Render.cpp VertexManager.cpp - ShaderCache.cpp ) set(LIBS diff --git a/Source/Core/VideoBackends/Null/NullBackend.cpp b/Source/Core/VideoBackends/Null/NullBackend.cpp index 7a1691b9d5..2d5642f571 100644 --- a/Source/Core/VideoBackends/Null/NullBackend.cpp +++ b/Source/Core/VideoBackends/Null/NullBackend.cpp @@ -12,7 +12,6 @@ #include "VideoBackends/Null/FramebufferManager.h" #include "VideoBackends/Null/PerfQuery.h" #include "VideoBackends/Null/Render.h" -#include "VideoBackends/Null/ShaderCache.h" #include "VideoBackends/Null/TextureCache.h" #include "VideoBackends/Null/VertexManager.h" #include "VideoBackends/Null/VideoBackend.h" @@ -32,13 +31,12 @@ namespace Null { -static void InitBackendInfo() +void VideoBackend::InitBackendInfo() { g_Config.backend_info.APIType = API_NONE; g_Config.backend_info.bSupportsExclusiveFullscreen = true; g_Config.backend_info.bSupportsDualSourceBlend = true; g_Config.backend_info.bSupportsEarlyZ = true; - g_Config.backend_info.bSupportsPrimitiveRestart = true; g_Config.backend_info.bSupportsOversizedViewports = true; g_Config.backend_info.bSupportsGeometryShaders = true; g_Config.backend_info.bSupports3DVision = false; @@ -50,39 +48,11 @@ static void InitBackendInfo() g_Config.backend_info.AAModes = {1}; } -void VideoBackend::ShowConfig(void* parent) -{ - InitBackendInfo(); - Host_ShowVideoConfig(parent, GetDisplayName(), "gfx_null"); -} - bool VideoBackend::Initialize(void* window_handle) { InitializeShared(); InitBackendInfo(); - // Load Configs - g_Config.Load(File::GetUserPath(D_CONFIG_IDX) + "GFX.ini"); - g_Config.GameIniLoad(); - g_Config.UpdateProjectionHack(); - g_Config.VerifyValidity(); - UpdateActiveConfig(); - - // Do our OSD callbacks - OSD::DoCallbacks(OSD::CallbackType::Initialization); - - // Initialize VideoCommon - CommandProcessor::Init(); - PixelEngine::Init(); - BPInit(); - Fifo::Init(); - OpcodeDecoder::Init(); - IndexGenerator::Init(); - VertexShaderManager::Init(); - PixelShaderManager::Init(); - VertexLoaderManager::Init(); - Host_Message(WM_USER_CREATE); - return true; } @@ -95,29 +65,16 @@ void VideoBackend::Video_Prepare() g_perf_query = std::make_unique(); g_framebuffer_manager = std::make_unique(); g_texture_cache = std::make_unique(); - VertexShaderCache::s_instance = std::make_unique(); - GeometryShaderCache::s_instance = std::make_unique(); - PixelShaderCache::s_instance = std::make_unique(); } void VideoBackend::Shutdown() { - // Shutdown VideoCommon - Fifo::Shutdown(); - VertexLoaderManager::Shutdown(); - VertexShaderManager::Shutdown(); - PixelShaderManager::Shutdown(); - OpcodeDecoder::Shutdown(); - - // Do our OSD callbacks - OSD::DoCallbacks(OSD::CallbackType::Shutdown); + ShutdownShared(); } void VideoBackend::Video_Cleanup() { - PixelShaderCache::s_instance.reset(); - VertexShaderCache::s_instance.reset(); - GeometryShaderCache::s_instance.reset(); + CleanupShared(); g_texture_cache.reset(); g_perf_query.reset(); g_vertex_manager.reset(); diff --git a/Source/Core/VideoBackends/Null/Render.cpp b/Source/Core/VideoBackends/Null/Render.cpp index fa26955ced..0e0eb536a9 100644 --- a/Source/Core/VideoBackends/Null/Render.cpp +++ b/Source/Core/VideoBackends/Null/Render.cpp @@ -38,7 +38,7 @@ TargetRectangle Renderer::ConvertEFBRectangle(const EFBRectangle& rc) return result; } -void Renderer::SwapImpl(u32, u32, u32, u32, const EFBRectangle&, float) +void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, const EFBRectangle& rc, u64 ticks, float gamma) { UpdateActiveConfig(); } diff --git a/Source/Core/VideoBackends/Null/Render.h b/Source/Core/VideoBackends/Null/Render.h index e436ce8123..6fdc36ad86 100644 --- a/Source/Core/VideoBackends/Null/Render.h +++ b/Source/Core/VideoBackends/Null/Render.h @@ -12,18 +12,17 @@ class Renderer : public ::Renderer { public: Renderer(); - ~Renderer(); + ~Renderer() override; void RenderText(const std::string& pstr, int left, int top, u32 color) override; u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) override { return 0; } void PokeEFB(EFBAccessType type, const EfbPokeData* points, size_t num_points) override {} u16 BBoxRead(int index) override { return 0; } void BBoxWrite(int index, u16 value) override {} - int GetMaxTextureSize() override { return 16 * 1024; } TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc) override; void SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, const EFBRectangle& rc, - float gamma) override; + u64 ticks, float gamma) override; void ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z) override @@ -31,9 +30,5 @@ class Renderer : public ::Renderer } void ReinterpretPixelData(unsigned int convtype) override {} - bool SaveScreenshot(const std::string& filename, const TargetRectangle& rc) override - { - return false; - } }; } diff --git a/Source/Core/VideoBackends/Null/ShaderCache.cpp b/Source/Core/VideoBackends/Null/ShaderCache.cpp deleted file mode 100644 index e0fa000765..0000000000 --- a/Source/Core/VideoBackends/Null/ShaderCache.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2015 Dolphin Emulator Project -// Licensed under GPLv2+ -// Refer to the license.txt file included. - -#include "VideoBackends/Null/ShaderCache.h" - -#include "VideoCommon/Debugger.h" -#include "VideoCommon/Statistics.h" - -namespace Null -{ -template -ShaderCache::ShaderCache() -{ - Clear(); - - SETSTAT(stats.numPixelShadersCreated, 0); - SETSTAT(stats.numPixelShadersAlive, 0); -} - -template -ShaderCache::~ShaderCache() -{ - Clear(); -} - -template -void ShaderCache::Clear() -{ - m_shaders.clear(); - m_last_entry = nullptr; -} - -template -bool ShaderCache::SetShader(DSTALPHA_MODE dst_alpha_mode, u32 primitive_type) -{ - Uid uid = GetUid(dst_alpha_mode, primitive_type, API_OPENGL); - - // Check if the shader is already set - if (m_last_entry) - { - if (uid == m_last_uid) - { - return true; - } - } - - m_last_uid = uid; - - // Check if the shader is already in the cache - auto iter = m_shaders.find(uid); - if (iter != m_shaders.end()) - { - const std::string& entry = iter->second; - m_last_entry = &entry; - - GFX_DEBUGGER_PAUSE_AT(NEXT_PIXEL_SHADER_CHANGE, true); - return true; - } - - // Need to compile a new shader - ShaderCode code = GenerateCode(dst_alpha_mode, primitive_type, API_OPENGL); - m_shaders.emplace(uid, code.GetBuffer()); - - GFX_DEBUGGER_PAUSE_AT(NEXT_PIXEL_SHADER_CHANGE, true); - return true; -} - -template class ShaderCache; -template class ShaderCache; -template class ShaderCache; - -std::unique_ptr VertexShaderCache::s_instance; -std::unique_ptr GeometryShaderCache::s_instance; -std::unique_ptr PixelShaderCache::s_instance; -} diff --git a/Source/Core/VideoBackends/Null/ShaderCache.h b/Source/Core/VideoBackends/Null/ShaderCache.h deleted file mode 100644 index 833c8acf36..0000000000 --- a/Source/Core/VideoBackends/Null/ShaderCache.h +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2015 Dolphin Emulator Project -// Licensed under GPLv2+ -// Refer to the license.txt file included. - -#pragma once - -#include -#include - -#include "VideoCommon/GeometryShaderGen.h" -#include "VideoCommon/PixelShaderGen.h" -#include "VideoCommon/VertexShaderGen.h" -#include "VideoCommon/VideoCommon.h" - -namespace Null -{ -template -class ShaderCache -{ -public: - ShaderCache(); - virtual ~ShaderCache(); - - void Clear(); - bool SetShader(DSTALPHA_MODE dst_alpha_mode, u32 primitive_type); - -protected: - virtual Uid GetUid(DSTALPHA_MODE dst_alpha_mode, u32 primitive_type, API_TYPE api_type) = 0; - virtual ShaderCode GenerateCode(DSTALPHA_MODE dst_alpha_mode, u32 primitive_type, - API_TYPE api_type) = 0; - -private: - std::map m_shaders; - const std::string* m_last_entry = nullptr; - Uid m_last_uid; - UidChecker m_uid_checker; -}; - -class VertexShaderCache : public ShaderCache -{ -public: - static std::unique_ptr s_instance; - -protected: - VertexShaderUid GetUid(DSTALPHA_MODE dst_alpha_mode, u32 primitive_type, - API_TYPE api_type) override - { - return GetVertexShaderUid(api_type); - } - ShaderCode GenerateCode(DSTALPHA_MODE dst_alpha_mode, u32 primitive_type, - API_TYPE api_type) override - { - return GenerateVertexShaderCode(api_type); - } -}; - -class GeometryShaderCache : public ShaderCache -{ -public: - static std::unique_ptr s_instance; - -protected: - GeometryShaderUid GetUid(DSTALPHA_MODE dst_alpha_mode, u32 primitive_type, - API_TYPE api_type) override - { - return GetGeometryShaderUid(primitive_type, api_type); - } - ShaderCode GenerateCode(DSTALPHA_MODE dst_alpha_mode, u32 primitive_type, - API_TYPE api_type) override - { - return GenerateGeometryShaderCode(primitive_type, api_type); - } -}; - -class PixelShaderCache : public ShaderCache -{ -public: - static std::unique_ptr s_instance; - -protected: - PixelShaderUid GetUid(DSTALPHA_MODE dst_alpha_mode, u32 primitive_type, - API_TYPE api_type) override - { - return GetPixelShaderUid(dst_alpha_mode, api_type); - } - ShaderCode GenerateCode(DSTALPHA_MODE dst_alpha_mode, u32 primitive_type, - API_TYPE api_type) override - { - return GeneratePixelShaderCode(dst_alpha_mode, api_type); - } -}; - -} // namespace NULL diff --git a/Source/Core/VideoBackends/Null/TextureCache.h b/Source/Core/VideoBackends/Null/TextureCache.h index d6ee5b3b7c..1941323c90 100644 --- a/Source/Core/VideoBackends/Null/TextureCache.h +++ b/Source/Core/VideoBackends/Null/TextureCache.h @@ -13,33 +13,34 @@ class TextureCache : public TextureCacheBase public: TextureCache() {} ~TextureCache() {} - void CompileShaders() override {} + bool CompileShaders() override { return true; } void DeleteShaders() override {} - void ConvertTexture(TCacheEntryBase* entry, TCacheEntryBase* unconverted, void* palette, - TlutFormat format) override - { - } - void CopyEFB(u8* dst, u32 format, u32 native_width, u32 bytes_per_row, u32 num_blocks_y, - u32 memory_stride, PEControl::PixelFormat src_format, const EFBRectangle& src_rect, - bool is_intensity, bool scale_by_half) override + void CopyEFB(u8* dst, const EFBCopyFormat& format, u32 native_width, u32 bytes_per_row, + u32 num_blocks_y, u32 memory_stride, + bool is_depth_copy, const EFBRectangle& src_rect, bool scale_by_half) override { } + PC_TexFormat GetNativeTextureFormat(const s32 texformat, + const TlutFormat tlutfmt, u32 width, u32 height) override + {return PC_TexFormat::PC_TEX_FMT_NONE;} + + bool Palettize(TCacheEntryBase* entry, const TCacheEntryBase* base_entry) override {return false;} + void LoadLut(u32 lutFmt, void* addr, u32 size) override {} private: struct TCacheEntry : TCacheEntryBase { TCacheEntry(const TCacheEntryConfig& _config) : TCacheEntryBase(_config) {} ~TCacheEntry() {} - void Load(unsigned int width, unsigned int height, unsigned int expanded_width, - unsigned int level) override + uintptr_t GetInternalObject() {return 0;} + void Load(const u8* buffer, u32 width, u32 height, u32 expanded_width, u32 level) override {} + void FromRenderTarget(bool is_depth_copy, const EFBRectangle& src_rect, bool scale_by_half, + u32 cbufid, const float* colmat, u32 width, u32 height) override { } - void FromRenderTarget(u8* dst, PEControl::PixelFormat src_format, const EFBRectangle& src_rect, - bool scale_by_half, unsigned int cbufid, const float* colmat) override - { - } + bool SupportsMaterialMap() const {return false;} void CopyRectangleFromTexture(const TCacheEntryBase* source, const MathUtil::Rectangle& srcrect, diff --git a/Source/Core/VideoBackends/Null/VertexManager.cpp b/Source/Core/VideoBackends/Null/VertexManager.cpp index d70876cb84..7f2b36a88c 100644 --- a/Source/Core/VideoBackends/Null/VertexManager.cpp +++ b/Source/Core/VideoBackends/Null/VertexManager.cpp @@ -3,7 +3,6 @@ // Refer to the license.txt file included. #include "VideoBackends/Null/VertexManager.h" -#include "VideoBackends/Null/ShaderCache.h" #include "VideoCommon/IndexGenerator.h" #include "VideoCommon/Statistics.h" @@ -15,14 +14,14 @@ namespace Null class NullNativeVertexFormat : public NativeVertexFormat { public: - NullNativeVertexFormat() {} + NullNativeVertexFormat(const PortableVertexDeclaration& _vtx_decl) {vtx_decl = _vtx_decl;} void SetupVertexPointers() override {} }; -NativeVertexFormat* +std::unique_ptr VertexManager::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) { - return new NullNativeVertexFormat; + return std::make_unique(vtx_decl); } VertexManager::VertexManager() : m_local_v_buffer(MAXVBUFFERSIZE), m_local_i_buffer(MAXIBUFFERSIZE) @@ -35,19 +34,11 @@ VertexManager::~VertexManager() void VertexManager::ResetBuffer(u32 stride) { - s_pCurBufferPointer = s_pBaseBufferPointer = m_local_v_buffer.data(); - s_pEndBufferPointer = s_pCurBufferPointer + m_local_v_buffer.size(); + m_pCurBufferPointer = m_pBaseBufferPointer = m_local_v_buffer.data(); + m_pEndBufferPointer = m_pCurBufferPointer + m_local_v_buffer.size(); IndexGenerator::Start(&m_local_i_buffer[0]); } -void VertexManager::vFlush(bool use_dst_alpha) -{ - VertexShaderCache::s_instance->SetShader( - use_dst_alpha ? DSTALPHA_DUAL_SOURCE_BLEND : DSTALPHA_NONE, current_primitive_type); - GeometryShaderCache::s_instance->SetShader( - use_dst_alpha ? DSTALPHA_DUAL_SOURCE_BLEND : DSTALPHA_NONE, current_primitive_type); - PixelShaderCache::s_instance->SetShader( - use_dst_alpha ? DSTALPHA_DUAL_SOURCE_BLEND : DSTALPHA_NONE, current_primitive_type); -} +void VertexManager::vFlush(bool use_dst_alpha) {} } // namespace diff --git a/Source/Core/VideoBackends/Null/VertexManager.h b/Source/Core/VideoBackends/Null/VertexManager.h index 9e31b30416..e9898fc290 100644 --- a/Source/Core/VideoBackends/Null/VertexManager.h +++ b/Source/Core/VideoBackends/Null/VertexManager.h @@ -15,8 +15,9 @@ class VertexManager : public VertexManagerBase public: VertexManager(); ~VertexManager(); - NativeVertexFormat* CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) override; + std::unique_ptr CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) override; + void PrepareShaders(PrimitiveType primitive, u32 components, const XFMemory &xfr, const BPMemory &bpm, bool ongputhread) override {} protected: void ResetBuffer(u32 stride) override; @@ -24,5 +25,7 @@ class VertexManager : public VertexManagerBase void vFlush(bool use_dst_alpha) override; std::vector m_local_v_buffer; std::vector m_local_i_buffer; + + u16* GetIndexBuffer() override {return m_local_i_buffer.data();} }; } diff --git a/Source/Core/VideoBackends/Null/VideoBackend.h b/Source/Core/VideoBackends/Null/VideoBackend.h index e83f4b8279..43a02e3e9b 100644 --- a/Source/Core/VideoBackends/Null/VideoBackend.h +++ b/Source/Core/VideoBackends/Null/VideoBackend.h @@ -14,11 +14,11 @@ class VideoBackend : public VideoBackendBase void Shutdown() override; std::string GetName() const override { return "Null"; } - std::string GetDisplayName() const override { return "Null"; } void Video_Prepare() override; void Video_Cleanup() override; - void ShowConfig(void* parent) override; + void InitBackendInfo() override; + void PrepareWindow(void* window_handle) override {}; unsigned int PeekMessages() override { return 0; } }; diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp index 954a308ad5..38ddf578a6 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.cpp +++ b/Source/Core/VideoCommon/VertexManagerBase.cpp @@ -318,4 +318,4 @@ void VertexManagerBase::CalculateZSlope(const PortableVertexDeclaration &vert_de m_zslope.dfdy = -b * c; m_zslope.f0 = out[2] - (out[0] * m_zslope.dfdx + out[1] * m_zslope.dfdy); m_zslope_refresh_required = true; -} \ No newline at end of file +} diff --git a/Source/Core/VideoCommon/VideoBackendBase.cpp b/Source/Core/VideoCommon/VideoBackendBase.cpp index 24a24ebaa4..5e93e12257 100644 --- a/Source/Core/VideoCommon/VideoBackendBase.cpp +++ b/Source/Core/VideoCommon/VideoBackendBase.cpp @@ -110,7 +110,7 @@ void VideoBackendBase::PopulateList() // Disable software video backend as is currently not working //g_available_video_backends.push_back(std::make_unique()); - g_available_video_backends.push_back(std::make_unique()); + g_available_video_backends.push_back(std::make_unique()); for (auto& backend : g_available_video_backends) {