SoftGPU with Vulkan runs but displays black

This commit is contained in:
Henrik Rydgard 2016-03-20 20:04:49 +01:00
parent 0b1cfaf751
commit 29bc07eb0a
8 changed files with 21 additions and 14 deletions

View file

@ -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;

View file

@ -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.";

View file

@ -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());
@ -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)

View file

@ -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();

View file

@ -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;
@ -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) {

View file

@ -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;
@ -102,4 +104,7 @@ private:
GEBufferFormat displayFormat_;
GraphicsContext *gfxCtx_;
Thin3DTexture *fbTex;
Thin3DContext *thin3d;
std::vector<u32> fbTexBuffer;
};

View file

@ -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 = "";

View file

@ -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;
}