Skip to content

Commit

Permalink
SoftGPU with Vulkan runs but displays black
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Mar 20, 2016
1 parent 0b1cfaf commit 29bc07e
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 14 deletions.
4 changes: 3 additions & 1 deletion Core/CoreParameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,16 @@ enum GPUCore {
class FileLoader;

class GraphicsContext;
class Thin3DContext;

// PSP_CoreParameter()
struct CoreParameter {
CoreParameter() : collectEmuLog(0), unthrottle(false), fpsLimit(0), updateRecent(true), freezeNext(false), frozen(false), mountIsoLoader(nullptr) {}
CoreParameter() : thin3d(nullptr), collectEmuLog(0), unthrottle(false), fpsLimit(0), updateRecent(true), freezeNext(false), frozen(false), mountIsoLoader(nullptr) {}

CPUCore cpuCore;
GPUCore gpuCore;
GraphicsContext *graphicsContext; // TODO: Find a better place.
Thin3DContext *thin3d;
bool enableSound; // there aren't multiple sound cores.

std::string fileToStart;
Expand Down
2 changes: 1 addition & 1 deletion Core/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ bool PSP_InitUpdate(std::string *error_string) {
bool success = coreParameter.fileToStart != "";
*error_string = coreParameter.errorString;
if (success) {
success = GPU_Init(coreParameter.graphicsContext);
success = GPU_Init(coreParameter.graphicsContext, coreParameter.thin3d);
if (!success) {
PSP_Shutdown();
*error_string = "Unable to initialize rendering engine.";
Expand Down
5 changes: 3 additions & 2 deletions GPU/GPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ static void SetGPU(T *obj) {
#ifdef USE_CRT_DBG
#undef new
#endif
bool GPU_Init(GraphicsContext *ctx) {

bool GPU_Init(GraphicsContext *ctx, Thin3DContext *thin3d) {
switch (PSP_CoreParameter().gpuCore) {
case GPU_NULL:
SetGPU(new NullGPU());
Expand All @@ -54,7 +55,7 @@ bool GPU_Init(GraphicsContext *ctx) {
SetGPU(new GLES_GPU(ctx));
break;
case GPU_SOFTWARE:
SetGPU(new SoftGPU(ctx));
SetGPU(new SoftGPU(ctx, thin3d));
break;
case GPU_DIRECTX9:
#if defined(_WIN32)
Expand Down
4 changes: 3 additions & 1 deletion GPU/GPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,7 @@ extern GPUStatistics gpuStats;
extern GPUInterface *gpu;
extern GPUDebugInterface *gpuDebug;

bool GPU_Init(GraphicsContext *ctx);
class Thin3DContext;

bool GPU_Init(GraphicsContext *ctx, Thin3DContext *thin3d);
void GPU_Shutdown();
10 changes: 2 additions & 8 deletions GPU/Software/SoftGpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,14 @@ FormatBuffer fb;
FormatBuffer depthbuf;
u32 clut[4096];

static Thin3DContext *thin3d = nullptr;
static Thin3DTexture *fbTex = nullptr;
static Thin3DVertexFormat *vformat = nullptr;
static Thin3DDepthStencilState *depth = nullptr;
static Thin3DBuffer *vdata = nullptr;
static Thin3DBuffer *idata = nullptr;
static std::vector<u32> fbTexBuffer;

SoftGPU::SoftGPU(GraphicsContext *gfxCtx)
: gfxCtx_(gfxCtx)
SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Thin3DContext *_thin3D)
: gfxCtx_(gfxCtx), thin3d(_thin3D)
{
thin3d = gfxCtx_->CreateThin3DContext();
fbTex = thin3d->CreateTexture(LINEAR2D, RGBA8888, 480, 272, 1, 1);

std::vector<Thin3DVertexComponent> components;
Expand Down Expand Up @@ -87,8 +83,6 @@ SoftGPU::~SoftGPU() {
vformat = nullptr;
fbTex->Release();
fbTex = nullptr;
thin3d->Release();
thin3d = nullptr;
}

void SoftGPU::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) {
Expand Down
7 changes: 6 additions & 1 deletion GPU/Software/SoftGpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ typedef struct {
} FormatBuffer;

class ShaderManager;
class Thin3DContext;
class Thin3DTexture;

class SoftGPU : public GPUCommon {
public:
SoftGPU(GraphicsContext *gfxCtx);
SoftGPU(GraphicsContext *gfxCtx, Thin3DContext *_thin3D);
~SoftGPU();
void InitClear() override {}
void ExecuteOp(u32 op, u32 diff) override;
Expand Down Expand Up @@ -102,4 +104,7 @@ class SoftGPU : public GPUCommon {
GEBufferFormat displayFormat_;

GraphicsContext *gfxCtx_;
Thin3DTexture *fbTex;
Thin3DContext *thin3d;
std::vector<u32> fbTexBuffer;
};
1 change: 1 addition & 0 deletions UI/EmuScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ void EmuScreen::bootGame(const std::string &filename) {
}
// Preserve the existing graphics context.
coreParam.graphicsContext = PSP_CoreParameter().graphicsContext;
coreParam.thin3d = screenManager()->getThin3DContext();
coreParam.enableSound = g_Config.bEnableSound;
coreParam.fileToStart = filename;
coreParam.mountIso = "";
Expand Down
2 changes: 2 additions & 0 deletions ext/native/thin3d/thin3d_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,8 @@ void Thin3DVKContext::Begin(bool clear, uint32_t colorval, float depthVal, int s
VkResult result = vkResetDescriptorPool(device_, frame->descriptorPool, 0);
assert(result == VK_SUCCESS);

noScissor_.extent.width = pixel_xres;
noScissor_.extent.height = pixel_yres;
scissorDirty_ = true;
viewportDirty_ = true;
}
Expand Down

0 comments on commit 29bc07e

Please sign in to comment.