Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null video backend #317

Open
wants to merge 3 commits into
base: slippi
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Source/Core/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ set(LIBS
vcdcom
vcddec
vcdenc
videonull
videoogl
videosoftware
z
Expand Down
1 change: 1 addition & 0 deletions Source/Core/VideoBackends/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
add_subdirectory(OGL)
add_subdirectory(Null)
add_subdirectory(Software)
add_subdirectory(Vulkan)

Expand Down
13 changes: 13 additions & 0 deletions Source/Core/VideoBackends/Null/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
set(SRCS
NullBackend.cpp
Render.cpp
VertexManager.cpp
)

set(LIBS
videocommon
common
)

add_dolphin_library(videonull "${SRCS}" "${LIBS}")

29 changes: 29 additions & 0 deletions Source/Core/VideoBackends/Null/FramebufferManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2015 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "VideoCommon/FramebufferManagerBase.h"

class XFBSource : public XFBSourceBase
{
public:
void DecodeToTexture(u32 xfb_addr, u32 fb_width, u32 fb_height) override {}
void CopyEFB(float gamma) override {}
};

class FramebufferManager : public FramebufferManagerBase
{
public:
std::unique_ptr<XFBSourceBase> CreateXFBSource(unsigned int target_width,
unsigned int target_height,
unsigned int layers) override
{
return std::make_unique<XFBSource>();
}

void GetTargetSize(unsigned int* width, unsigned int* height) override {}
void CopyToRealXFB(u32 xfb_addr, u32 fb_stride, u32 fb_height, const EFBRectangle& source_rc,
float gamma = 1.0f) override
{
}
};
84 changes: 84 additions & 0 deletions Source/Core/VideoBackends/Null/NullBackend.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Copyright 2015 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

// Null Backend Documentation

// This backend tries not to do anything in the backend,
// but everything in VideoCommon.

#include "Core/Host.h"

#include "VideoBackends/Null/FramebufferManager.h"
#include "VideoBackends/Null/PerfQuery.h"
#include "VideoBackends/Null/Render.h"
#include "VideoBackends/Null/TextureCache.h"
#include "VideoBackends/Null/VertexManager.h"
#include "VideoBackends/Null/VideoBackend.h"

#include "VideoCommon/BPStructs.h"
#include "VideoCommon/CommandProcessor.h"
#include "VideoCommon/Fifo.h"
#include "VideoCommon/IndexGenerator.h"
#include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/OpcodeDecoding.h"
#include "VideoCommon/PixelEngine.h"
#include "VideoCommon/PixelShaderManager.h"
#include "VideoCommon/VertexLoaderManager.h"
#include "VideoCommon/VertexShaderManager.h"
#include "VideoCommon/VideoBackendBase.h"
#include "VideoCommon/VideoConfig.h"

namespace Null
{
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.bSupportsOversizedViewports = true;
g_Config.backend_info.bSupportsGeometryShaders = true;
g_Config.backend_info.bSupports3DVision = false;
g_Config.backend_info.bSupportsPostProcessing = false;
g_Config.backend_info.bSupportsPaletteConversion = true;
g_Config.backend_info.bSupportsClipControl = true;

// aamodes: We only support 1 sample, so no MSAA
g_Config.backend_info.AAModes = {1};
}

bool VideoBackend::Initialize(void* window_handle)
{
InitializeShared();
InitBackendInfo();

return true;
}

// This is called after Initialize() from the Core
// Run from the graphics thread
void VideoBackend::Video_Prepare()
{
g_renderer = std::make_unique<Renderer>();
g_vertex_manager = std::make_unique<VertexManager>();
g_perf_query = std::make_unique<PerfQuery>();
g_framebuffer_manager = std::make_unique<FramebufferManager>();
g_texture_cache = std::make_unique<TextureCache>();
}

void VideoBackend::Shutdown()
{
ShutdownShared();
}

void VideoBackend::Video_Cleanup()
{
CleanupShared();
g_texture_cache.reset();
g_perf_query.reset();
g_vertex_manager.reset();
g_framebuffer_manager.reset();
g_renderer.reset();
}
}
24 changes: 24 additions & 0 deletions Source/Core/VideoBackends/Null/PerfQuery.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2015 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include "VideoCommon/PerfQueryBase.h"

namespace Null
{
class PerfQuery : public PerfQueryBase
{
public:
PerfQuery() {}
~PerfQuery() override {}
void EnableQuery(PerfQueryGroup type) override {}
void DisableQuery(PerfQueryGroup type) override {}
void ResetQuery() override {}
u32 GetQueryResult(PerfQueryType type) override { return 0; }
void FlushResults() override {}
bool IsFlushed() const { return true; }
};

} // namespace
46 changes: 46 additions & 0 deletions Source/Core/VideoBackends/Null/Render.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright 2015 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "Common/Logging/Log.h"

#include "VideoBackends/Null/Render.h"

#include "VideoCommon/VideoConfig.h"

namespace Null
{
// Init functions
Renderer::Renderer()
{
g_Config.bRunning = true;
UpdateActiveConfig();
}

Renderer::~Renderer()
{
g_Config.bRunning = false;
UpdateActiveConfig();
}

void Renderer::RenderText(const std::string& text, int left, int top, u32 color)
{
NOTICE_LOG(VIDEO, "RenderText: %s\n", text.c_str());
}

TargetRectangle Renderer::ConvertEFBRectangle(const EFBRectangle& rc)
{
TargetRectangle result;
result.left = rc.left;
result.top = rc.top;
result.right = rc.right;
result.bottom = rc.bottom;
return result;
}

void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, const EFBRectangle& rc, u64 ticks, float gamma)
{
UpdateActiveConfig();
}

} // namespace Null
34 changes: 34 additions & 0 deletions Source/Core/VideoBackends/Null/Render.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2015 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include "VideoCommon/RenderBase.h"

namespace Null
{
class Renderer : public ::Renderer
{
public:
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 {}
TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc) override;

void SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, const EFBRectangle& rc,
u64 ticks, float gamma) override;

void ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable,
u32 color, u32 z) override
{
}

void ReinterpretPixelData(unsigned int convtype) override {}
};
}
61 changes: 61 additions & 0 deletions Source/Core/VideoBackends/Null/TextureCache.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2015 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include "VideoCommon/TextureCacheBase.h"

namespace Null
{
class TextureCache : public TextureCacheBase
{
public:
TextureCache() {}
~TextureCache() {}
bool CompileShaders() override { return true; }
void DeleteShaders() 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() {}
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
{
}

bool SupportsMaterialMap() const {return false;}

void CopyRectangleFromTexture(const TCacheEntryBase* source,
const MathUtil::Rectangle<int>& srcrect,
const MathUtil::Rectangle<int>& dstrect) override
{
}

void Bind(unsigned int stage) override {}
bool Save(const std::string& filename, unsigned int level) override { return false; }
};

TCacheEntryBase* CreateTexture(const TCacheEntryConfig& config) override
{
return new TCacheEntry(config);
}
};

} // Null name space
44 changes: 44 additions & 0 deletions Source/Core/VideoBackends/Null/VertexManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2015 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "VideoBackends/Null/VertexManager.h"

#include "VideoCommon/IndexGenerator.h"
#include "VideoCommon/Statistics.h"
#include "VideoCommon/VertexLoaderManager.h"
#include "VideoCommon/VideoConfig.h"

namespace Null
{
class NullNativeVertexFormat : public NativeVertexFormat
{
public:
NullNativeVertexFormat(const PortableVertexDeclaration& _vtx_decl) {vtx_decl = _vtx_decl;}
void SetupVertexPointers() override {}
};

std::unique_ptr<NativeVertexFormat>
VertexManager::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl)
{
return std::make_unique<NullNativeVertexFormat>(vtx_decl);
}

VertexManager::VertexManager() : m_local_v_buffer(MAXVBUFFERSIZE), m_local_i_buffer(MAXIBUFFERSIZE)
{
}

VertexManager::~VertexManager()
{
}

void VertexManager::ResetBuffer(u32 stride)
{
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) {}

} // namespace
31 changes: 31 additions & 0 deletions Source/Core/VideoBackends/Null/VertexManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2015 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include <vector>

#include "VideoCommon/VertexManagerBase.h"

namespace Null
{
class VertexManager : public VertexManagerBase
{
public:
VertexManager();
~VertexManager();
std::unique_ptr<NativeVertexFormat> 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;

private:
void vFlush(bool use_dst_alpha) override;
std::vector<u8> m_local_v_buffer;
std::vector<u16> m_local_i_buffer;

u16* GetIndexBuffer() override {return m_local_i_buffer.data();}
};
}
Loading
Loading