From 4fdeeace6630dec84dd9e6e3da6adc818bbf4f77 Mon Sep 17 00:00:00 2001 From: DH Date: Mon, 5 Oct 2015 03:42:48 +0300 Subject: [PATCH] D3D12Renderer: fixed some compilation errors Removed GSFrameBase2 and D3DGSFrame. Added frame for NullRender. Minor improvements and fixes --- rpcs3/Emu/RSX/Common/TextureUtils.h | 6 +- rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp | 391 ++++++++++-------- rpcs3/Emu/RSX/D3D12/D3D12GSRender.h | 59 +-- rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp | 10 +- rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp | 70 ++-- rpcs3/Emu/RSX/GCM.h | 29 +- rpcs3/Emu/RSX/GL/GLGSRender.cpp | 79 +--- rpcs3/Emu/RSX/GL/GLGSRender.h | 2 - rpcs3/Emu/RSX/GL/gl_helpers.cpp | 8 +- rpcs3/Emu/RSX/GL/gl_helpers.h | 28 +- rpcs3/Emu/RSX/GSManager.h | 2 +- rpcs3/Emu/RSX/GSRender.cpp | 55 +++ rpcs3/Emu/RSX/GSRender.h | 30 +- rpcs3/Emu/RSX/Null/NullGSRender.cpp | 16 + rpcs3/Emu/RSX/Null/NullGSRender.h | 29 +- rpcs3/Emu/RSX/RSXThread.cpp | 40 +- rpcs3/Emu/RSX/RSXThread.h | 4 +- rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp | 5 +- rpcs3/Emu/System.h | 2 +- rpcs3/Gui/D3DGSFrame.cpp | 103 ----- rpcs3/Gui/D3DGSFrame.h | 36 -- rpcs3/Gui/GLGSFrame.cpp | 87 +--- rpcs3/Gui/GLGSFrame.h | 18 +- rpcs3/Gui/GSFrame.cpp | 113 +++-- rpcs3/Gui/GSFrame.h | 29 +- rpcs3/emucore.vcxproj | 1 + rpcs3/emucore.vcxproj.filters | 3 + rpcs3/rpcs3.cpp | 23 +- rpcs3/rpcs3.vcxproj | 2 - rpcs3/rpcs3.vcxproj.filters | 6 - 30 files changed, 609 insertions(+), 677 deletions(-) create mode 100644 rpcs3/Emu/RSX/Null/NullGSRender.cpp delete mode 100644 rpcs3/Gui/D3DGSFrame.cpp delete mode 100644 rpcs3/Gui/D3DGSFrame.h diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.h b/rpcs3/Emu/RSX/Common/TextureUtils.h index 6a5e5ae295..4ed2981bfd 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.h +++ b/rpcs3/Emu/RSX/Common/TextureUtils.h @@ -10,17 +10,15 @@ struct MipmapLevelInfo size_t rowPitch; }; -unsigned LinearToSwizzleAddress(unsigned x, unsigned y, unsigned z, unsigned log2_width, unsigned log2_height, unsigned log2_depth); - /** * Get size to store texture in a linear fashion. * Storage is assumed to use a rowPitchAlignement boundary for every row of texture. */ -size_t getPlacedTextureStorageSpace(const RSXTexture &texture, size_t rowPitchAlignement); +size_t getPlacedTextureStorageSpace(const rsx::texture &texture, size_t rowPitchAlignement); /** * Write texture data to textureData. * Data are not packed, they are stored per rows using rowPitchAlignement. * Similarly, offset for every mipmaplevel is aligned to rowPitchAlignement boundary. */ -std::vector uploadPlacedTexture(const RSXTexture &texture, size_t rowPitchAlignement, void* textureData); \ No newline at end of file +std::vector uploadPlacedTexture(const rsx::texture &texture, size_t rowPitchAlignement, void* textureData); \ No newline at end of file diff --git a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp index 8b6bc6b54d..a2858fd9ee 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp @@ -33,13 +33,6 @@ static void unloadD3D12FunctionPointers() FreeLibrary(D3D11Module); } -GetGSFrameCb2 GetGSFrame = nullptr; - -void SetGetD3DGSFrameCallback(GetGSFrameCb2 value) -{ - GetGSFrame = value; -} - void D3D12GSRender::ResourceStorage::Reset() { m_constantsBufferIndex = 0; @@ -136,7 +129,7 @@ D3D12DLLManagement::~D3D12DLLManagement() } D3D12GSRender::D3D12GSRender() - : GSRender(), m_D3D12Lib(), m_PSO(nullptr) + : GSRender(frame_type::DX12), m_D3D12Lib(), m_PSO(nullptr) { m_previous_address_a = 0; m_previous_address_b = 0; @@ -174,13 +167,14 @@ D3D12GSRender::D3D12GSRender() g_descriptorStrideRTV = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV); g_descriptorStrideSamplers = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); - m_frame = GetGSFrame(); - + DXGI_ADAPTER_DESC adaptaterDesc; + adaptater->GetDesc(&adaptaterDesc); + m_frame->title_message(adaptaterDesc.Description); // Create swap chain and put them in a descriptor heap as rendertarget DXGI_SWAP_CHAIN_DESC swapChain = {}; swapChain.BufferCount = 2; swapChain.Windowed = true; - swapChain.OutputWindow = m_frame->getHandle(); + swapChain.OutputWindow = (HWND)m_frame->handle(); swapChain.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; swapChain.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; swapChain.SampleDesc.Count = 1; @@ -297,40 +291,20 @@ D3D12GSRender::~D3D12GSRender() ReleaseD2DStructures(); } -void D3D12GSRender::Close() -{ - if (joinable()) - { - join(); - } - - if (m_frame->IsShown()) - { - m_frame->Hide(); - } -} - -void D3D12GSRender::OnInit() -{ - m_frame->Show(); -} - -void D3D12GSRender::OnInitThread() +void D3D12GSRender::oninit_thread() { } -void D3D12GSRender::OnExitThread() +void D3D12GSRender::onexit_thread() { } -void D3D12GSRender::OnReset() +void D3D12GSRender::clear_surface(u32 arg) { -} + if ((arg & 0xf3) == 0) + return; -void D3D12GSRender::Clear(u32 cmd) -{ std::chrono::time_point startDuration = std::chrono::system_clock::now(); - assert(cmd == NV4097_CLEAR_SURFACE); std::chrono::time_point rttDurationStart = std::chrono::system_clock::now(); PrepareRenderTargets(getCurrentResourceStorage().m_commandList.Get()); @@ -338,64 +312,77 @@ void D3D12GSRender::Clear(u32 cmd) std::chrono::time_point rttDurationEnd = std::chrono::system_clock::now(); m_timers.m_rttDuration += std::chrono::duration_cast(rttDurationEnd - rttDurationStart).count(); -/* if (m_set_color_mask) - { - glColorMask(m_color_mask_r, m_color_mask_g, m_color_mask_b, m_color_mask_a); - checkForGlError("glColorMask"); - } + u32 scissor_horizontal = rsx::method_registers[NV4097_SET_SCISSOR_HORIZONTAL]; + u32 scissor_vertical = rsx::method_registers[NV4097_SET_SCISSOR_VERTICAL]; + u16 scissor_x = scissor_horizontal; + u16 scissor_w = scissor_horizontal >> 16; + u16 scissor_y = scissor_vertical; + u16 scissor_h = scissor_vertical >> 16; - if (m_set_scissor_horizontal && m_set_scissor_vertical) - { - glScissor(m_scissor_x, m_scissor_y, m_scissor_w, m_scissor_h); - checkForGlError("glScissor"); - }*/ + D3D12_RECT scissor; + scissor.left = scissor_x; + scissor.top = scissor_y; + scissor.right = scissor_x + scissor_w; + scissor.bottom = scissor_y + scissor_h; // TODO: Merge depth and stencil clear when possible - if (m_clear_surface_mask & 0x1) + if (arg & 0x1) { - u32 max_depth_value = m_surface_depth_format == CELL_GCM_SURFACE_Z16 ? 0x0000ffff : 0x00ffffff; - getCurrentResourceStorage().m_commandList->ClearDepthStencilView(m_rtts.m_depthStencilDescriptorHeap->GetCPUDescriptorHandleForHeapStart(), D3D12_CLEAR_FLAG_DEPTH, m_clear_surface_z / (float)max_depth_value, 0, 0, nullptr); + u32 surface_depth_format = (rsx::method_registers[NV4097_SET_SURFACE_FORMAT] >> 5) & 0x7; + u32 max_depth_value = surface_depth_format == CELL_GCM_SURFACE_Z16 ? 0x0000ffff : 0x00ffffff; + u32 clear_depth = rsx::method_registers[NV4097_SET_ZSTENCIL_CLEAR_VALUE] >> 8; + + getCurrentResourceStorage().m_commandList->ClearDepthStencilView(m_rtts.m_depthStencilDescriptorHeap->GetCPUDescriptorHandleForHeapStart(), D3D12_CLEAR_FLAG_DEPTH, clear_depth / (float)max_depth_value, 0, 0, &scissor); } - if (m_clear_surface_mask & 0x2) - getCurrentResourceStorage().m_commandList->ClearDepthStencilView(m_rtts.m_depthStencilDescriptorHeap->GetCPUDescriptorHandleForHeapStart(), D3D12_CLEAR_FLAG_STENCIL, 0.f, m_clear_surface_s, 0, nullptr); - - if (m_clear_surface_mask & 0xF0) + if (arg & 0x2) { + u8 clear_stencil = rsx::method_registers[NV4097_SET_ZSTENCIL_CLEAR_VALUE] & 0xff; + getCurrentResourceStorage().m_commandList->ClearDepthStencilView(m_rtts.m_depthStencilDescriptorHeap->GetCPUDescriptorHandleForHeapStart(), D3D12_CLEAR_FLAG_STENCIL, 0.f, clear_stencil, 0, &scissor); + } + + if (arg & 0xF0) + { + u32 clear_color = rsx::method_registers[NV4097_SET_COLOR_CLEAR_VALUE]; + u8 clear_a = clear_color >> 24; + u8 clear_r = clear_color >> 16; + u8 clear_g = clear_color >> 8; + u8 clear_b = clear_color; + float clearColor[] = { - m_clear_surface_color_r / 255.0f, - m_clear_surface_color_g / 255.0f, - m_clear_surface_color_b / 255.0f, - m_clear_surface_color_a / 255.0f + clear_r / 255.0f, + clear_g / 255.0f, + clear_b / 255.0f, + clear_a / 255.0f }; size_t g_RTTIncrement = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV); - switch (m_surface_color_target) + switch (u32 color_target = rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]) { - case CELL_GCM_SURFACE_TARGET_NONE: break; + case CELL_GCM_SURFACE_TARGET_NONE: break; - case CELL_GCM_SURFACE_TARGET_0: - case CELL_GCM_SURFACE_TARGET_1: - getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()), clearColor, 0, nullptr); - break; - case CELL_GCM_SURFACE_TARGET_MRT1: - getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()), clearColor, 0, nullptr); - getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(1, g_descriptorStrideRTV), clearColor, 0, nullptr); - break; - case CELL_GCM_SURFACE_TARGET_MRT2: - getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()), clearColor, 0, nullptr); - getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(1, g_descriptorStrideRTV), clearColor, 0, nullptr); - getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(2, g_descriptorStrideRTV), clearColor, 0, nullptr); - break; - case CELL_GCM_SURFACE_TARGET_MRT3: - getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()), clearColor, 0, nullptr); - getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(1, g_descriptorStrideRTV), clearColor, 0, nullptr); - getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(2, g_descriptorStrideRTV), clearColor, 0, nullptr); - getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(3, g_descriptorStrideRTV), clearColor, 0, nullptr); - break; - default: - LOG_ERROR(RSX, "Bad surface color target: %d", m_surface_color_target); + case CELL_GCM_SURFACE_TARGET_0: + case CELL_GCM_SURFACE_TARGET_1: + getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()), clearColor, 0, &scissor); + break; + case CELL_GCM_SURFACE_TARGET_MRT1: + getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()), clearColor, 0, &scissor); + getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(1, g_descriptorStrideRTV), clearColor, 0, &scissor); + break; + case CELL_GCM_SURFACE_TARGET_MRT2: + getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()), clearColor, 0, &scissor); + getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(1, g_descriptorStrideRTV), clearColor, 0, &scissor); + getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(2, g_descriptorStrideRTV), clearColor, 0, &scissor); + break; + case CELL_GCM_SURFACE_TARGET_MRT3: + getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()), clearColor, 0, &scissor); + getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(1, g_descriptorStrideRTV), clearColor, 0, &scissor); + getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(2, g_descriptorStrideRTV), clearColor, 0, &scissor); + getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(3, g_descriptorStrideRTV), clearColor, 0, &scissor); + break; + default: + LOG_ERROR(RSX, "Bad surface color target: %d", color_target); } } @@ -411,7 +398,24 @@ void D3D12GSRender::Clear(u32 cmd) } } -void D3D12GSRender::Draw() +bool D3D12GSRender::domethod(u32 id, u32 arg) +{ + switch (id) + { + case NV4097_CLEAR_SURFACE: + clear_surface(arg); + return true; + + default: + return false; + } +} + +void D3D12GSRender::begin() +{ +} + +void D3D12GSRender::end() { std::chrono::time_point startDuration = std::chrono::system_clock::now(); @@ -424,9 +428,10 @@ void D3D12GSRender::Draw() std::chrono::time_point vertexIndexDurationStart = std::chrono::system_clock::now(); // Init vertex count - if (m_indexed_array.m_count) + if (!vertex_index_array.empty()) { - for (u32 i = 0; i < m_vertex_count; ++i) + /* + for (u32 i = 0; i < rsx::limits::vertex_count; ++i) { if (!m_vertex_data[i].IsEnabled()) continue; if (!m_vertex_data[i].addr) continue; @@ -434,24 +439,25 @@ void D3D12GSRender::Draw() const u32 tsize = m_vertex_data[i].GetTypeSize(); m_vertexBufferSize[i] = (m_indexed_array.index_min + m_indexed_array.index_max - m_indexed_array.index_min + 1) * tsize * m_vertex_data[i].size; } + */ } else { - for (u32 i = 0; i < m_vertex_count; ++i) + for (u32 i = 0; i < rsx::limits::vertex_count; ++i) { - if (!m_vertex_data[i].IsEnabled()) continue; - if (!m_vertex_data[i].addr) continue; + auto &info = vertex_arrays_info[i]; + if (info.size == 0) + continue; - const u32 tsize = m_vertex_data[i].GetTypeSize(); - m_vertexBufferSize[i] = (m_draw_array_first + m_draw_array_count) * tsize * m_vertex_data[i].size; + m_vertexBufferSize[i] = (draw_array_first + draw_array_count) * rsx::get_vertex_type_size(info.type) * info.size; } } - if (m_indexed_array.m_count || m_draw_array_count) + if (draw_array_count) { - const std::vector &vertexBufferViews = UploadVertexBuffers(m_indexed_array.m_count ? true : false); - const D3D12_INDEX_BUFFER_VIEW &indexBufferView = uploadIndexBuffers(m_indexed_array.m_count ? true : false); + const std::vector &vertexBufferViews = UploadVertexBuffers(!vertex_index_array.empty()); + const D3D12_INDEX_BUFFER_VIEW &indexBufferView = uploadIndexBuffers(!vertex_index_array.empty()); getCurrentResourceStorage().m_commandList->IASetVertexBuffers(0, (UINT)vertexBufferViews.size(), vertexBufferViews.data()); if (m_renderingInfo.m_indexed) getCurrentResourceStorage().m_commandList->IASetIndexBuffer(&indexBufferView); @@ -471,7 +477,7 @@ void D3D12GSRender::Draw() m_timers.m_programLoadDuration += std::chrono::duration_cast(programLoadEnd - programLoadStart).count(); getCurrentResourceStorage().m_commandList->SetGraphicsRootSignature(m_rootSignatures[m_PSO->second].Get()); - getCurrentResourceStorage().m_commandList->OMSetStencilRef(m_stencil_func_ref); + getCurrentResourceStorage().m_commandList->OMSetStencilRef(rsx::method_registers[NV4097_SET_STENCIL_FUNC_REF]); std::chrono::time_point constantsDurationStart = std::chrono::system_clock::now(); @@ -553,7 +559,7 @@ void D3D12GSRender::Draw() m_timers.m_textureDuration += std::chrono::duration_cast(textureDurationEnd - textureDurationStart).count(); size_t numRTT; - switch (m_surface_color_target) + switch (u32 color_target = rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]) { case CELL_GCM_SURFACE_TARGET_NONE: break; case CELL_GCM_SURFACE_TARGET_0: @@ -570,18 +576,24 @@ void D3D12GSRender::Draw() numRTT = 4; break; default: - LOG_ERROR(RSX, "Bad surface color target: %d", m_surface_color_target); + LOG_ERROR(RSX, "Bad surface color target: %d", color_target); } getCurrentResourceStorage().m_commandList->OMSetRenderTargets((UINT)numRTT, &m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart(), true, &CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_depthStencilDescriptorHeap->GetCPUDescriptorHandleForHeapStart())); + u32 clip_horizontal = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL]; + u32 clip_vertical = rsx::method_registers[NV4097_SET_SURFACE_CLIP_VERTICAL]; + + u32 clip_width = clip_horizontal >> 16; + u32 clip_height = clip_vertical >> 16; + D3D12_VIEWPORT viewport = { 0.f, 0.f, - (float)m_surface_clip_w, - (float)m_surface_clip_h, + (float)clip_width, + (float)clip_height, -1.f, 1.f }; @@ -591,12 +603,12 @@ void D3D12GSRender::Draw() { 0, 0, - (LONG)m_surface_clip_w, - (LONG)m_surface_clip_h, + (LONG)clip_width, + (LONG)clip_height, }; getCurrentResourceStorage().m_commandList->RSSetScissorRects(1, &box); - switch (m_draw_mode - 1) + switch (draw_mode - 1) { case GL_POINTS: getCurrentResourceStorage().m_commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_POINTLIST); @@ -633,7 +645,6 @@ void D3D12GSRender::Draw() else getCurrentResourceStorage().m_commandList->DrawInstanced((UINT)m_renderingInfo.m_count, 1, (UINT)m_renderingInfo.m_baseVertex, 0); - m_indexed_array.Reset(); std::chrono::time_point endDuration = std::chrono::system_clock::now(); m_timers.m_drawCallDuration += std::chrono::duration_cast(endDuration - startDuration).count(); m_timers.m_drawCallCount++; @@ -663,12 +674,12 @@ isFlipSurfaceInLocalMemory(u32 surfaceColorTarget) } } -void D3D12GSRender::Flip() +void D3D12GSRender::flip(int buffer) { ID3D12Resource *resourceToFlip; float viewport_w, viewport_h; - if (!isFlipSurfaceInLocalMemory(m_surface_color_target)) + if (!isFlipSurfaceInLocalMemory(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])) { ResourceStorage &storage = getCurrentResourceStorage(); assert(storage.m_RAMFramebuffer == nullptr); @@ -676,12 +687,11 @@ void D3D12GSRender::Flip() size_t w = 0, h = 0, rowPitch = 0; size_t offset = 0; - if (m_read_buffer) + if (false/*m_read_buffer*/) { - CellGcmDisplayInfo* buffers = vm::get_ptr(m_gcm_buffers_addr); - u32 addr = GetAddress(buffers[m_gcm_current_buffer].offset, CELL_GCM_LOCATION_LOCAL); - w = buffers[m_gcm_current_buffer].width; - h = buffers[m_gcm_current_buffer].height; + u32 addr = rsx::get_address(gcm_buffers[gcm_current_buffer].offset, CELL_GCM_LOCATION_LOCAL); + w = gcm_buffers[gcm_current_buffer].width; + h = gcm_buffers[gcm_current_buffer].height; u8 *src_buffer = vm::get_ptr(addr); rowPitch = align(w * 4, 256); @@ -751,7 +761,7 @@ void D3D12GSRender::Flip() srvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; srvDesc.Texture2D.MipLevels = 1; - if (isFlipSurfaceInLocalMemory(m_surface_color_target)) + if (isFlipSurfaceInLocalMemory(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET])) srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; else srvDesc.Shader4ComponentMapping = D3D12_ENCODE_SHADER_4_COMPONENT_MAPPING( @@ -792,7 +802,7 @@ void D3D12GSRender::Flip() if (!Ini.GSOverlay.GetValue()) getCurrentResourceStorage().m_commandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_backBuffer[m_swapChain->GetCurrentBackBufferIndex()].Get(), D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT)); - if (isFlipSurfaceInLocalMemory(m_surface_color_target) && m_rtts.m_currentlyBoundRenderTargets[0] != nullptr) + if (isFlipSurfaceInLocalMemory(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]) && m_rtts.m_currentlyBoundRenderTargets[0] != nullptr) getCurrentResourceStorage().m_commandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_rtts.m_currentlyBoundRenderTargets[0], D3D12_RESOURCE_STATE_GENERIC_READ, D3D12_RESOURCE_STATE_RENDER_TARGET)); ThrowIfFailed(getCurrentResourceStorage().m_commandList->Close()); m_commandQueueGraphic->ExecuteCommandLists(1, (ID3D12CommandList**)getCurrentResourceStorage().m_commandList.GetAddressOf()); @@ -841,8 +851,7 @@ void D3D12GSRender::Flip() m_UAVHeap.m_getPos = newStorage.m_getPosUAVHeap; } - m_frame->Flip(nullptr); - + m_frame->flip(nullptr); std::chrono::time_point flipEnd = std::chrono::system_clock::now(); m_timers.m_flipDuration += std::chrono::duration_cast(flipEnd - flipStart).count(); @@ -874,10 +883,14 @@ D3D12GSRender::ResourceStorage& D3D12GSRender::getNonCurrentResourceStorage() ID3D12Resource * D3D12GSRender::writeColorBuffer(ID3D12Resource * RTT, ID3D12GraphicsCommandList * cmdlist) { ID3D12Resource *Result; - size_t w = m_surface_clip_w, h = m_surface_clip_h; + + u32 clip_width = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL] >> 16; + u32 clip_height = rsx::method_registers[NV4097_SET_SURFACE_CLIP_VERTICAL] >> 16; + + size_t w = clip_width, h = clip_height; DXGI_FORMAT dxgiFormat; size_t rowPitch; - switch (m_surface_color_format) + switch (rsx::method_registers[NV4097_SET_SURFACE_FORMAT] & 0x1f) { case CELL_GCM_SURFACE_A8R8G8B8: dxgiFormat = DXGI_FORMAT_R8G8B8A8_UNORM; @@ -943,17 +956,33 @@ void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value) HANDLE handle = CreateEvent(0, FALSE, FALSE, 0); fence->SetEventOnCompletion(1, handle); + u32 clip_width = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL] >> 16; + u32 clip_height = rsx::method_registers[NV4097_SET_SURFACE_CLIP_VERTICAL] >> 16; + ComPtr writeDest, depthConverted; ComPtr descriptorHeap; - size_t depthRowPitch = m_surface_clip_w; + size_t depthRowPitch = clip_width; depthRowPitch = (depthRowPitch + 255) & ~255; - bool needTransfer = (m_set_context_dma_z && Ini.GSDumpDepthBuffer.GetValue()) || - ((m_set_context_dma_color_a || m_set_context_dma_color_b || m_set_context_dma_color_c || m_set_context_dma_color_d) && Ini.GSDumpColorBuffers.GetValue()); + u32 dma_color_a = rsx::method_registers[NV4097_SET_CONTEXT_DMA_COLOR_A]; + u32 dma_color_b = rsx::method_registers[NV4097_SET_CONTEXT_DMA_COLOR_B]; + u32 dma_color_c = rsx::method_registers[NV4097_SET_CONTEXT_DMA_COLOR_C]; + u32 dma_color_d = rsx::method_registers[NV4097_SET_CONTEXT_DMA_COLOR_D]; + u32 dma_z = rsx::method_registers[NV4097_SET_CONTEXT_DMA_ZETA]; - if (m_set_context_dma_z && Ini.GSDumpDepthBuffer.GetValue()) + u32 offset_color_a = rsx::method_registers[NV4097_SET_SURFACE_COLOR_AOFFSET]; + u32 offset_color_b = rsx::method_registers[NV4097_SET_SURFACE_COLOR_BOFFSET]; + u32 offset_color_c = rsx::method_registers[NV4097_SET_SURFACE_COLOR_COFFSET]; + u32 offset_color_d = rsx::method_registers[NV4097_SET_SURFACE_COLOR_DOFFSET]; + + u32 offset_z = rsx::method_registers[NV4097_SET_SURFACE_ZETA_OFFSET]; + + bool needTransfer = (dma_z && Ini.GSDumpDepthBuffer.GetValue()) || + ((dma_color_a || dma_color_b || dma_color_c || dma_color_d) && Ini.GSDumpColorBuffers.GetValue()); + + if (dma_z && Ini.GSDumpDepthBuffer.GetValue()) { - size_t sizeInByte = m_surface_clip_w * m_surface_clip_h * 2; + size_t sizeInByte = clip_width * clip_height * 2; assert(m_UAVHeap.canAlloc(sizeInByte)); size_t heapOffset = m_UAVHeap.alloc(sizeInByte); @@ -961,14 +990,14 @@ void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value) m_device->CreatePlacedResource( m_UAVHeap.m_heap, heapOffset, - &CD3DX12_RESOURCE_DESC::Tex2D(DXGI_FORMAT_R8_UNORM, m_surface_clip_w, m_surface_clip_h, 1, 1, 1, 0, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS), + &CD3DX12_RESOURCE_DESC::Tex2D(DXGI_FORMAT_R8_UNORM, clip_width, clip_height, 1, 1, 1, 0, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS), D3D12_RESOURCE_STATE_UNORDERED_ACCESS, nullptr, IID_PPV_ARGS(depthConverted.GetAddressOf()) ) ); - sizeInByte = depthRowPitch * m_surface_clip_h; + sizeInByte = depthRowPitch * clip_height; assert(m_readbackResources.canAlloc(sizeInByte)); heapOffset = m_readbackResources.alloc(sizeInByte); @@ -988,7 +1017,7 @@ void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value) m_device->CreateDescriptorHeap(&descriptorHeapDesc, IID_PPV_ARGS(descriptorHeap.GetAddressOf())) ); D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; - switch (m_surface_depth_format) + switch (u32 depth_format = ((rsx::method_registers[NV4097_SET_SURFACE_FORMAT] >> 5) & 0x7)) { case 0: break; @@ -999,7 +1028,7 @@ void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value) srvDesc.Format = DXGI_FORMAT_R24_UNORM_X8_TYPELESS; break; default: - LOG_ERROR(RSX, "Bad depth format! (%d)", m_surface_depth_format); + LOG_ERROR(RSX, "Bad depth format! (%d)", depth_format); assert(0); } srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; @@ -1020,7 +1049,7 @@ void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value) getCurrentResourceStorage().m_commandList->SetComputeRootSignature(m_convertRootSignature); getCurrentResourceStorage().m_commandList->SetDescriptorHeaps(1, descriptorHeap.GetAddressOf()); getCurrentResourceStorage().m_commandList->SetComputeRootDescriptorTable(0, descriptorHeap->GetGPUDescriptorHandleForHeapStart()); - getCurrentResourceStorage().m_commandList->Dispatch(m_surface_clip_w / 8, m_surface_clip_h / 8, 1); + getCurrentResourceStorage().m_commandList->Dispatch(clip_width / 8, clip_height / 8, 1); D3D12_RESOURCE_BARRIER barriers[] = { @@ -1029,52 +1058,50 @@ void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value) }; getCurrentResourceStorage().m_commandList->ResourceBarrier(2, barriers); getCurrentResourceStorage().m_commandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(depthConverted.Get(), D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE)); - getCurrentResourceStorage().m_commandList->CopyTextureRegion(&CD3DX12_TEXTURE_COPY_LOCATION(writeDest.Get(), { 0, { DXGI_FORMAT_R8_UNORM, m_surface_clip_w, m_surface_clip_h, 1, (UINT)depthRowPitch } }), 0, 0, 0, + getCurrentResourceStorage().m_commandList->CopyTextureRegion(&CD3DX12_TEXTURE_COPY_LOCATION(writeDest.Get(), { 0, { DXGI_FORMAT_R8_UNORM, clip_width, clip_height, 1, (UINT)depthRowPitch } }), 0, 0, 0, &CD3DX12_TEXTURE_COPY_LOCATION(depthConverted.Get(), 0), nullptr); - - invalidateAddress(GetAddress(m_surface_offset_z, m_context_dma_z - 0xfeed0000)); - } + invalidateTexture(rsx::get_address(offset_z, dma_z - 0xfeed0000)); } ID3D12Resource *rtt0, *rtt1, *rtt2, *rtt3; if (Ini.GSDumpColorBuffers.GetValue()) { - switch (m_surface_color_target) + switch (u32 color_target = rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]) { case CELL_GCM_SURFACE_TARGET_NONE: break; case CELL_GCM_SURFACE_TARGET_0: - if (m_context_dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get()); + if (dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get()); break; case CELL_GCM_SURFACE_TARGET_1: - if (m_context_dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get()); + if (dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get()); break; case CELL_GCM_SURFACE_TARGET_MRT1: - if (m_context_dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get()); - if (m_context_dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[1], getCurrentResourceStorage().m_commandList.Get()); + if (dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get()); + if (dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[1], getCurrentResourceStorage().m_commandList.Get()); break; case CELL_GCM_SURFACE_TARGET_MRT2: - if (m_context_dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get()); - if (m_context_dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[1], getCurrentResourceStorage().m_commandList.Get()); - if (m_context_dma_color_c) rtt2 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[2], getCurrentResourceStorage().m_commandList.Get()); + if (dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get()); + if (dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[1], getCurrentResourceStorage().m_commandList.Get()); + if (dma_color_c) rtt2 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[2], getCurrentResourceStorage().m_commandList.Get()); break; case CELL_GCM_SURFACE_TARGET_MRT3: - if (m_context_dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get()); - if (m_context_dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[1], getCurrentResourceStorage().m_commandList.Get()); - if (m_context_dma_color_c) rtt2 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[2], getCurrentResourceStorage().m_commandList.Get()); - if (m_context_dma_color_d) rtt3 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[3], getCurrentResourceStorage().m_commandList.Get()); + if (dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get()); + if (dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[1], getCurrentResourceStorage().m_commandList.Get()); + if (dma_color_c) rtt2 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[2], getCurrentResourceStorage().m_commandList.Get()); + if (dma_color_d) rtt3 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[3], getCurrentResourceStorage().m_commandList.Get()); break; } - if (m_context_dma_color_a) invalidateAddress(GetAddress(m_surface_offset_a, m_context_dma_color_a - 0xfeed0000)); - if (m_context_dma_color_b) invalidateAddress(GetAddress(m_surface_offset_b, m_context_dma_color_b - 0xfeed0000)); - if (m_context_dma_color_c) invalidateAddress(GetAddress(m_surface_offset_c, m_context_dma_color_c - 0xfeed0000)); - if (m_context_dma_color_d) invalidateAddress(GetAddress(m_surface_offset_d, m_context_dma_color_d - 0xfeed0000)); - } + if (dma_color_a) invalidateTexture(rsx::get_address(offset_color_a, dma_color_a - 0xfeed0000)); + if (dma_color_b) invalidateTexture(rsx::get_address(offset_color_b, dma_color_b - 0xfeed0000)); + if (dma_color_c) invalidateTexture(rsx::get_address(offset_color_c, dma_color_c - 0xfeed0000)); + if (dma_color_d) invalidateTexture(rsx::get_address(offset_color_d, dma_color_d - 0xfeed0000)); + } if (needTransfer) { ThrowIfFailed(getCurrentResourceStorage().m_commandList->Close()); @@ -1087,103 +1114,103 @@ void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value) WaitForSingleObject(handle, INFINITE); CloseHandle(handle); - if (m_set_context_dma_z && Ini.GSDumpDepthBuffer.GetValue()) + if (dma_z && Ini.GSDumpDepthBuffer.GetValue()) { - u32 address = GetAddress(m_surface_offset_z, m_context_dma_z - 0xfeed0000); + u32 address = rsx::get_address(offset_z, dma_z - 0xfeed0000); auto ptr = vm::get_ptr(address); char *ptrAsChar = (char*)ptr; unsigned char *writeDestPtr; ThrowIfFailed(writeDest->Map(0, nullptr, (void**)&writeDestPtr)); - for (unsigned row = 0; row < m_surface_clip_h; row++) + for (unsigned row = 0; row < clip_height; row++) { - for (unsigned i = 0; i < m_surface_clip_w; i++) + for (unsigned i = 0; i < clip_width; i++) { unsigned char c = writeDestPtr[row * depthRowPitch + i]; - ptrAsChar[4 * (row * m_surface_clip_w + i)] = c; - ptrAsChar[4 * (row * m_surface_clip_w + i) + 1] = c; - ptrAsChar[4 * (row * m_surface_clip_w + i) + 2] = c; - ptrAsChar[4 * (row * m_surface_clip_w + i) + 3] = c; + ptrAsChar[4 * (row * clip_width + i)] = c; + ptrAsChar[4 * (row * clip_width + i) + 1] = c; + ptrAsChar[4 * (row * clip_width + i) + 2] = c; + ptrAsChar[4 * (row * clip_width + i) + 3] = c; } } } size_t srcPitch, dstPitch; - switch (m_surface_color_format) + switch (rsx::method_registers[NV4097_SET_SURFACE_FORMAT] & 0x1f) { case CELL_GCM_SURFACE_A8R8G8B8: - srcPitch = align(m_surface_clip_w * 4, 256); - dstPitch = m_surface_clip_w * 4; + srcPitch = align(clip_width * 4, 256); + dstPitch = clip_width * 4; break; case CELL_GCM_SURFACE_F_W16Z16Y16X16: - srcPitch = align(m_surface_clip_w * 8, 256); - dstPitch = m_surface_clip_w * 8; + srcPitch = align(clip_width * 8, 256); + dstPitch = clip_width * 8; break; } if (Ini.GSDumpColorBuffers.GetValue()) { - switch (m_surface_color_target) + switch (u32 color_target = rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]) { case CELL_GCM_SURFACE_TARGET_NONE: break; case CELL_GCM_SURFACE_TARGET_0: { - u32 address = GetAddress(m_surface_offset_a, m_context_dma_color_a - 0xfeed0000); + u32 address = rsx::get_address(offset_color_a, dma_color_a - 0xfeed0000); void *dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt0, srcPitch, dstPitch, m_surface_clip_w, m_surface_clip_h); + copyToCellRamAndRelease(dstAddress, rtt0, srcPitch, dstPitch, clip_width, clip_height); } break; case CELL_GCM_SURFACE_TARGET_1: { - u32 address = GetAddress(m_surface_offset_b, m_context_dma_color_b - 0xfeed0000); + u32 address = rsx::get_address(offset_color_b, dma_color_b - 0xfeed0000); void *dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt1, srcPitch, dstPitch, m_surface_clip_w, m_surface_clip_h); + copyToCellRamAndRelease(dstAddress, rtt1, srcPitch, dstPitch, clip_width, clip_height); } break; case CELL_GCM_SURFACE_TARGET_MRT1: { - u32 address = GetAddress(m_surface_offset_a, m_context_dma_color_a - 0xfeed0000); + u32 address = rsx::get_address(offset_color_a, dma_color_a - 0xfeed0000); void *dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt0, srcPitch, dstPitch, m_surface_clip_w, m_surface_clip_h); - address = GetAddress(m_surface_offset_b, m_context_dma_color_b - 0xfeed0000); + copyToCellRamAndRelease(dstAddress, rtt0, srcPitch, dstPitch, clip_width, clip_height); + address = rsx::get_address(offset_color_b, dma_color_b - 0xfeed0000); dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt1, srcPitch, dstPitch, m_surface_clip_w, m_surface_clip_h); + copyToCellRamAndRelease(dstAddress, rtt1, srcPitch, dstPitch, clip_width, clip_height); } break; case CELL_GCM_SURFACE_TARGET_MRT2: { - u32 address = GetAddress(m_surface_offset_a, m_context_dma_color_a - 0xfeed0000); + u32 address = rsx::get_address(offset_color_a, dma_color_a - 0xfeed0000); void *dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt0, srcPitch, dstPitch, m_surface_clip_w, m_surface_clip_h); - address = GetAddress(m_surface_offset_b, m_context_dma_color_b - 0xfeed0000); + copyToCellRamAndRelease(dstAddress, rtt0, srcPitch, dstPitch, clip_width, clip_height); + address = rsx::get_address(offset_color_b, dma_color_b - 0xfeed0000); dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt1, srcPitch, dstPitch, m_surface_clip_w, m_surface_clip_h); - address = GetAddress(m_surface_offset_c, m_context_dma_color_c - 0xfeed0000); + copyToCellRamAndRelease(dstAddress, rtt1, srcPitch, dstPitch, clip_width, clip_height); + address = rsx::get_address(offset_color_c, dma_color_c - 0xfeed0000); dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt2, srcPitch, dstPitch, m_surface_clip_w, m_surface_clip_h); + copyToCellRamAndRelease(dstAddress, rtt2, srcPitch, dstPitch, clip_width, clip_height); } break; case CELL_GCM_SURFACE_TARGET_MRT3: { - u32 address = GetAddress(m_surface_offset_a, m_context_dma_color_a - 0xfeed0000); + u32 address = rsx::get_address(offset_color_a, dma_color_a - 0xfeed0000); void *dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt0, srcPitch, dstPitch, m_surface_clip_w, m_surface_clip_h); - address = GetAddress(m_surface_offset_b, m_context_dma_color_b - 0xfeed0000); + copyToCellRamAndRelease(dstAddress, rtt0, srcPitch, dstPitch, clip_width, clip_height); + address = rsx::get_address(offset_color_b, dma_color_b - 0xfeed0000); dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt1, srcPitch, dstPitch, m_surface_clip_w, m_surface_clip_h); - address = GetAddress(m_surface_offset_c, m_context_dma_color_c - 0xfeed0000); + copyToCellRamAndRelease(dstAddress, rtt1, srcPitch, dstPitch, clip_width, clip_height); + address = rsx::get_address(offset_color_c, dma_color_c - 0xfeed0000); dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt2, srcPitch, dstPitch, m_surface_clip_w, m_surface_clip_h); - address = GetAddress(m_surface_offset_d, m_context_dma_color_d - 0xfeed0000); + copyToCellRamAndRelease(dstAddress, rtt2, srcPitch, dstPitch, clip_width, clip_height); + address = rsx::get_address(offset_color_d, dma_color_d - 0xfeed0000); dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt3, srcPitch, dstPitch, m_surface_clip_w, m_surface_clip_h); + copyToCellRamAndRelease(dstAddress, rtt3, srcPitch, dstPitch, clip_width, clip_height); } break; } } - vm::write32(m_label_addr + offset, value); + vm::ps3::write32(label_addr + offset, value); } void D3D12GSRender::semaphorePFIFOAcquire(u32 offset, u32 value) @@ -1191,7 +1218,7 @@ void D3D12GSRender::semaphorePFIFOAcquire(u32 offset, u32 value) const std::chrono::time_point enterWait = std::chrono::system_clock::now(); while (true) { - volatile u32 val = vm::read32(m_label_addr + offset); + volatile u32 val = vm::ps3::read32(label_addr + offset); if (val == value) break; std::chrono::time_point waitPoint = std::chrono::system_clock::now(); long long elapsedTime = std::chrono::duration_cast(waitPoint - enterWait).count(); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h index a571b2fadc..d9ca443962 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h @@ -41,28 +41,6 @@ * are not currently correctly signaled which leads to deadlock. */ -class GSFrameBase2 -{ -public: - GSFrameBase2() {} - GSFrameBase2(const GSFrameBase2&) = delete; - virtual void Close() = 0; - - virtual bool IsShown() = 0; - virtual void Hide() = 0; - virtual void Show() = 0; - - virtual void* GetNewContext() = 0; - virtual void SetCurrent(void* ctx) = 0; - virtual void DeleteContext(void* ctx) = 0; - virtual void Flip(void* ctx) = 0; - virtual HWND getHandle() const = 0; -}; - -typedef GSFrameBase2*(*GetGSFrameCb2)(); - -void SetGetD3DGSFrameCallback(GetGSFrameCb2 value); - template struct InitHeap { @@ -470,28 +448,26 @@ private: u32 m_previous_address_d; u32 m_previous_address_z; public: - GSFrameBase2 *m_frame; u32 m_draw_frames; u32 m_skip_frames; - std::unordered_map m_vertexConstants; + std::unordered_map m_vertexConstants; D3D12GSRender(); virtual ~D3D12GSRender(); - virtual void semaphorePGRAPHTextureReadRelease(u32 offset, u32 value) override; - virtual void semaphorePGRAPHBackendRelease(u32 offset, u32 value) override; - virtual void semaphorePFIFOAcquire(u32 offset, u32 value) override; - virtual void notifyProgramChange() override; - virtual void notifyBlendStateChange() override; - virtual void notifyDepthStencilStateChange() override; - virtual void notifyRasterizerStateChange() override; + void semaphorePGRAPHTextureReadRelease(u32 offset, u32 value); + void semaphorePGRAPHBackendRelease(u32 offset, u32 value); + void semaphorePFIFOAcquire(u32 offset, u32 value); + void notifyProgramChange(); + void notifyBlendStateChange(); + void notifyDepthStencilStateChange(); + void notifyRasterizerStateChange(); private: void InitD2DStructures(); void ReleaseD2DStructures(); ID3D12Resource *writeColorBuffer(ID3D12Resource *RTT, ID3D12GraphicsCommandList *cmdlist); - virtual void Close() override; bool LoadProgram(); @@ -533,14 +509,19 @@ private: */ void renderOverlay(); + void clear_surface(u32 arg); + protected: - virtual void OnInit() override; - virtual void OnInitThread() override; - virtual void OnExitThread() override; - virtual void OnReset() override; - virtual void Clear(u32 cmd) override; - virtual void Draw() override; - virtual void Flip() override; + void begin() override; + void end() override; + + void oninit_thread() override; + void onexit_thread() override; + bool domethod(u32 id, u32 arg) override; + void flip(int buffer) override; + + //TODO + //u64 timestamp() const override; }; #endif \ No newline at end of file diff --git a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp index f9f8dc3f6c..5fc125835e 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp @@ -29,11 +29,11 @@ void D3D12GSRender::PrepareRenderTargets(ID3D12GraphicsCommandList *copycmdlist) m_previous_address_z = m_surface_offset_z; // FBO location has changed, previous data might be copied - u32 address_a = m_set_context_dma_color_a ? GetAddress(m_surface_offset_a, m_context_dma_color_a - 0xfeed0000) : 0; - u32 address_b = m_set_context_dma_color_b ? GetAddress(m_surface_offset_b, m_context_dma_color_b - 0xfeed0000) : 0; - u32 address_c = m_set_context_dma_color_c ? GetAddress(m_surface_offset_c, m_context_dma_color_c - 0xfeed0000) : 0; - u32 address_d = m_set_context_dma_color_d ? GetAddress(m_surface_offset_d, m_context_dma_color_d - 0xfeed0000) : 0; - u32 address_z = m_set_context_dma_z ? GetAddress(m_surface_offset_z, m_context_dma_z - 0xfeed0000) : 0; + u32 address_a = m_set_context_dma_color_a ? rsx::get_address(m_surface_offset_a, m_context_dma_color_a - 0xfeed0000) : 0; + u32 address_b = m_set_context_dma_color_b ? rsx::get_address(m_surface_offset_b, m_context_dma_color_b - 0xfeed0000) : 0; + u32 address_c = m_set_context_dma_color_c ? rsx::get_address(m_surface_offset_c, m_context_dma_color_c - 0xfeed0000) : 0; + u32 address_d = m_set_context_dma_color_d ? rsx::get_address(m_surface_offset_d, m_context_dma_color_d - 0xfeed0000) : 0; + u32 address_z = m_set_context_dma_z ? rsx::get_address(m_surface_offset_z, m_context_dma_z - 0xfeed0000) : 0; // Make previous RTTs sampleable for (unsigned i = 0; i < 4; i++) diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp index 6f71a2a41f..1b532f7366 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp @@ -104,19 +104,19 @@ D3D12_FILTER getSamplerFilter(u32 minFilter, u32 magFilter) } static -D3D12_SAMPLER_DESC getSamplerDesc(const RSXTexture &texture) +D3D12_SAMPLER_DESC getSamplerDesc(const rsx::texture &texture) { D3D12_SAMPLER_DESC samplerDesc = {}; - samplerDesc.Filter = getSamplerFilter(texture.GetMinFilter(), texture.GetMagFilter()); - samplerDesc.AddressU = getSamplerWrap(texture.GetWrapS()); - samplerDesc.AddressV = getSamplerWrap(texture.GetWrapT()); - samplerDesc.AddressW = getSamplerWrap(texture.GetWrapR()); - samplerDesc.ComparisonFunc = getSamplerCompFunc[texture.GetZfunc()]; - samplerDesc.MaxAnisotropy = (UINT)getSamplerMaxAniso(texture.GetMaxAniso()); - samplerDesc.MipLODBias = texture.GetBias(); - samplerDesc.BorderColor[4] = (FLOAT)texture.GetBorderColor(); - samplerDesc.MinLOD = (FLOAT)(texture.GetMinLOD() >> 8); - samplerDesc.MaxLOD = (FLOAT)(texture.GetMaxLOD() >> 8); + samplerDesc.Filter = getSamplerFilter(texture.min_filter(), texture.mag_filter()); + samplerDesc.AddressU = getSamplerWrap(texture.wrap_s()); + samplerDesc.AddressV = getSamplerWrap(texture.wrap_t()); + samplerDesc.AddressW = getSamplerWrap(texture.wrap_r()); + samplerDesc.ComparisonFunc = getSamplerCompFunc[texture.zfunc()]; + samplerDesc.MaxAnisotropy = (UINT)getSamplerMaxAniso(texture.max_aniso()); + samplerDesc.MipLODBias = texture.bias(); + samplerDesc.BorderColor[4] = (FLOAT)texture.border_color(); + samplerDesc.MinLOD = (FLOAT)(texture.min_lod() >> 8); + samplerDesc.MaxLOD = (FLOAT)(texture.max_lod() >> 8); return samplerDesc; } @@ -127,15 +127,15 @@ D3D12_SAMPLER_DESC getSamplerDesc(const RSXTexture &texture) */ static ComPtr uploadSingleTexture( - const RSXTexture &texture, + const rsx::texture &texture, ID3D12Device *device, ID3D12GraphicsCommandList *commandList, DataHeap &textureBuffersHeap) { ComPtr vramTexture; - size_t w = texture.GetWidth(), h = texture.GetHeight(); + size_t w = texture.width(), h = texture.height(); - int format = texture.GetFormat() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); + int format = texture.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); DXGI_FORMAT dxgiFormat = getTextureDXGIFormat(format); size_t textureSize = getPlacedTextureStorageSpace(texture, 256); @@ -148,7 +148,7 @@ ComPtr uploadSingleTexture( std::vector mipInfos = uploadPlacedTexture(texture, 256, textureData); textureBuffersHeap.m_heap->Unmap(0, &CD3DX12_RANGE(heapOffset, heapOffset + textureSize)); - D3D12_RESOURCE_DESC texturedesc = CD3DX12_RESOURCE_DESC::Tex2D(dxgiFormat, (UINT)w, (UINT)h, 1, texture.GetMipmap()); + D3D12_RESOURCE_DESC texturedesc = CD3DX12_RESOURCE_DESC::Tex2D(dxgiFormat, (UINT)w, (UINT)h, 1, texture.mipmap()); textureSize = device->GetResourceAllocationInfo(0, 1, &texturedesc).SizeInBytes; ThrowIfFailed(device->CreateCommittedResource( @@ -216,11 +216,11 @@ void updateExistingTexture( * Get number of bytes occupied by texture in RSX mem */ static -size_t getTextureSize(const RSXTexture &texture) +size_t getTextureSize(const rsx::texture &texture) { - size_t w = texture.GetWidth(), h = texture.GetHeight(); + size_t w = texture.width(), h = texture.height(); - int format = texture.GetFormat() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); + int format = texture.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); // TODO: Take mipmaps into account switch (format) { @@ -288,17 +288,17 @@ size_t D3D12GSRender::UploadTextures(ID3D12GraphicsCommandList *cmdlist) { size_t usedTexture = 0; - for (u32 i = 0; i < m_textures_count; ++i) + for (u32 i = 0; i < rsx::limits::textures_count; ++i) { - if (!m_textures[i].IsEnabled()) continue; - size_t w = m_textures[i].GetWidth(), h = m_textures[i].GetHeight(); + if (!textures[i].enabled()) continue; + size_t w = textures[i].width(), h = textures[i].height(); if (!w || !h) continue; - const u32 texaddr = GetAddress(m_textures[i].GetOffset(), m_textures[i].GetLocation()); + const u32 texaddr = rsx::get_address(textures[i].offset(), textures[i].location()); - int format = m_textures[i].GetFormat() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); + int format = textures[i].format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); DXGI_FORMAT dxgiFormat = getTextureDXGIFormat(format); - bool is_swizzled = !(m_textures[i].GetFormat() & CELL_GCM_TEXTURE_LN); + bool is_swizzled = !(textures[i].format() & CELL_GCM_TEXTURE_LN); ID3D12Resource *vramTexture; std::unordered_map::const_iterator ItRTT = m_rtts.m_renderTargets.find(texaddr); @@ -324,13 +324,13 @@ size_t D3D12GSRender::UploadTextures(ID3D12GraphicsCommandList *cmdlist) getCurrentResourceStorage().m_dirtyTextures.push_back(m_textureCache.removeFromCache(texaddr)); ComPtr tex = uploadSingleTexture(m_textures[i], m_device.Get(), cmdlist, m_textureUploadData); vramTexture = tex.Get(); - m_textureCache.storeAndProtectData(texaddr, texaddr, getTextureSize(m_textures[i]), format, w, h, m_textures[i].GetMipmap(), tex); + m_textureCache.storeAndProtectData(texaddr, texaddr, getTextureSize(m_textures[i]), format, w, h, m_textures[i].mipmap(), tex); } D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; srvDesc.Format = dxgiFormat; - srvDesc.Texture2D.MipLevels = m_textures[i].GetMipmap(); + srvDesc.Texture2D.MipLevels = textures[i].mipmap(); switch (format) { @@ -357,10 +357,10 @@ size_t D3D12GSRender::UploadTextures(ID3D12GraphicsCommandList *cmdlist) { - u8 remap_a = m_textures[i].GetRemap() & 0x3; - u8 remap_r = (m_textures[i].GetRemap() >> 2) & 0x3; - u8 remap_g = (m_textures[i].GetRemap() >> 4) & 0x3; - u8 remap_b = (m_textures[i].GetRemap() >> 6) & 0x3; + u8 remap_a = textures[i].remap() & 0x3; + u8 remap_r = (textures[i].remap() >> 2) & 0x3; + u8 remap_g = (textures[i].remap() >> 4) & 0x3; + u8 remap_b = (textures[i].remap() >> 6) & 0x3; if (isRenderTarget) { // ARGB format @@ -428,10 +428,10 @@ size_t D3D12GSRender::UploadTextures(ID3D12GraphicsCommandList *cmdlist) D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_1 }; - u8 remap_a = m_textures[i].GetRemap() & 0x3; - u8 remap_r = (m_textures[i].GetRemap() >> 2) & 0x3; - u8 remap_g = (m_textures[i].GetRemap() >> 4) & 0x3; - u8 remap_b = (m_textures[i].GetRemap() >> 6) & 0x3; + u8 remap_a = textures[i].remap() & 0x3; + u8 remap_r = (textures[i].remap() >> 2) & 0x3; + u8 remap_g = (textures[i].remap() >> 4) & 0x3; + u8 remap_b = (textures[i].remap() >> 6) & 0x3; srvDesc.Shader4ComponentMapping = D3D12_ENCODE_SHADER_4_COMPONENT_MAPPING( RemapValue[remap_a], @@ -459,7 +459,7 @@ size_t D3D12GSRender::UploadTextures(ID3D12GraphicsCommandList *cmdlist) getCurrentResourceStorage().m_samplerDescriptorHeapIndex = 1; getCurrentResourceStorage().m_currentSamplerIndex = 0; } - m_device->CreateSampler(&getSamplerDesc(m_textures[i]), + m_device->CreateSampler(&getSamplerDesc(textures[i]), CD3DX12_CPU_DESCRIPTOR_HANDLE(getCurrentResourceStorage().m_samplerDescriptorHeap[getCurrentResourceStorage().m_samplerDescriptorHeapIndex]->GetCPUDescriptorHandleForHeapStart()) .Offset((UINT)getCurrentResourceStorage().m_currentSamplerIndex + (UINT)usedTexture, g_descriptorStrideSamplers)); diff --git a/rpcs3/Emu/RSX/GCM.h b/rpcs3/Emu/RSX/GCM.h index f3cfb808e2..26906b275b 100644 --- a/rpcs3/Emu/RSX/GCM.h +++ b/rpcs3/Emu/RSX/GCM.h @@ -1,5 +1,6 @@ #pragma once #include "Utilities/types.h" +#include "Emu/Memory/vm.h" enum { @@ -242,6 +243,15 @@ enum CELL_GCM_TEXTURE_CYLINDRICAL_WRAP_ENABLE_TEX7_P = 1 << 30, CELL_GCM_TEXTURE_CYLINDRICAL_WRAP_ENABLE_TEX7_Q = 1 << 31, + // Texture Filter + CELL_GCM_TEXTURE_NEAREST = 1, + CELL_GCM_TEXTURE_LINEAR = 2, + CELL_GCM_TEXTURE_NEAREST_NEAREST = 3, + CELL_GCM_TEXTURE_LINEAR_NEAREST = 4, + CELL_GCM_TEXTURE_NEAREST_LINEAR = 5, + CELL_GCM_TEXTURE_LINEAR_LINEAR = 6, + CELL_GCM_TEXTURE_CONVOLUTION_MIN = 7, + CELL_GCM_PRIMITIVE_POINTS = 1, CELL_GCM_PRIMITIVE_LINES = 2, CELL_GCM_PRIMITIVE_LINE_LOOP = 3, @@ -893,7 +903,7 @@ enum Method namespace rsx { template - static std::initializer_list make_command(u32 start_register, T... values) + static std::array make_command(u32 start_register, T... values) { return{ (start_register << 2) | (sizeof...(values) << 18), values... }; } @@ -903,24 +913,23 @@ namespace rsx return CELL_GCM_METHOD_FLAG_JUMP | offset; } - template - static size_t make_command(vm::ps3::ptr& dst, u32 start_register, T... values) + template + static size_t make_command(vm::ps3::ptr &dst, u32 start_register, T... values) { - std::initializer_list commands = make_command(start_register, values...); + auto commands = make_command(start_register, values...); - for (auto &&command : commands) + for (u32 command : commands) { - vm::ps3::write32(dst.addr(), command); - dst++; + *dst++ = command; } return commands.size(); } - static size_t make_jump(vm::ps3::ptr& dst, u32 offset) + template + static size_t make_jump(vm::ps3::ptr &dst, u32 offset) { - vm::ps3::write32(dst.addr(), make_jump(offset)); - dst++; + *dst++ = make_jump(offset); return 1; } diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index f554bd2e1f..3586bc7cf1 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -530,15 +530,8 @@ u32 GLTexture::id() const return m_id; } -GLGSRender::GLGSRender() +GLGSRender::GLGSRender() : GSRender(frame_type::OpenGL) { - m_frame = Emu.GetCallbacks().get_gs_frame().release(); -} - -GLGSRender::~GLGSRender() -{ - m_context = nullptr; - m_frame->close(); } u32 GLGSRender::enable(u32 condition, u32 cap) @@ -571,19 +564,6 @@ u32 GLGSRender::enable(u32 condition, u32 cap, u32 index) extern CellGcmContextData current_context; -void GLGSRender::close() -{ - if (joinable()) - { - join(); - } - - if (m_frame->shown()) - { - m_frame->hide(); - } -} - void GLGSRender::begin() { rsx::thread::begin(); @@ -627,8 +607,8 @@ void GLGSRender::begin() if (enable(rsx::method_registers[NV4097_SET_DEPTH_TEST_ENABLE], GL_DEPTH_TEST)) { - //glcheck(glDepthFunc(rsx::method_registers[NV4097_SET_DEPTH_FUNC])); - //glcheck(glDepthMask(rsx::method_registers[NV4097_SET_DEPTH_MASK])); + __glcheck glDepthFunc(rsx::method_registers[NV4097_SET_DEPTH_FUNC]); + __glcheck glDepthMask(rsx::method_registers[NV4097_SET_DEPTH_MASK]); } if (enable(rsx::method_registers[NV4097_SET_DEPTH_BOUNDS_TEST_ENABLE], GL_DEPTH_BOUNDS_TEST_EXT)) @@ -855,42 +835,6 @@ void apply_attrib_array(gl::glsl::program& program, int index, const std::vector void GLGSRender::end() { - if (!vertex_draw_count) - { - bool has_array = false; - - for (int i = 0; i < rsx::limits::vertex_count; ++i) - { - if (vertex_arrays_info[i].array) - { - has_array = true; - break; - } - } - - if (!has_array) - { - u32 min_count = ~0; - - for (int i = 0; i < rsx::limits::vertex_count; ++i) - { - if (!vertex_arrays_info[i].size) - continue; - - u32 count = u32(vertex_arrays[i].size()) / - rsx::get_vertex_type_size(vertex_arrays_info[i].type) * vertex_arrays_info[i].size; - - if (count < min_count) - min_count = count; - } - - if (min_count && min_count < ~0) - { - vertex_draw_count = min_count; - } - } - } - if (!draw_fbo || !vertex_draw_count) { rsx::thread::end(); @@ -906,8 +850,12 @@ void GLGSRender::end() if (!textures[i].enabled()) continue; - __glcheck m_gl_textures[i].init(textures[i]); - __glcheck m_program.uniforms.texture("tex" + std::to_string(i), i, gl::texture_view(gl::texture::target::texture2D, m_gl_textures[i].id())); + int location; + if (m_program.uniforms.has_location("tex" + std::to_string(i), &location)) + { + __glcheck m_gl_textures[i].init(textures[i]); + __glcheck m_program.uniforms.texture(location, i, gl::texture_view(gl::texture::target::texture2D, m_gl_textures[i].id())); + } } //initialize vertex attributes @@ -1096,18 +1044,19 @@ void GLGSRender::end() void GLGSRender::oninit() { + GSRender::oninit(); + m_draw_frames = 1; m_skip_frames = 0; - - m_frame->show(); } void GLGSRender::oninit_thread() { - m_context = m_frame->new_context(); - m_frame->set_current(m_context); + GSRender::oninit_thread(); gl::init(); + LOG_NOTICE(Log::RSX, "%s", glGetString(GL_VERSION)); + LOG_NOTICE(Log::RSX, "%s", glGetString(GL_SHADING_LANGUAGE_VERSION)); is_intel_vendor = strstr((const char*)glGetString(GL_VENDOR), "Intel"); diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.h b/rpcs3/Emu/RSX/GL/GLGSRender.h index 99d982eea5..799a0afbf0 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.h +++ b/rpcs3/Emu/RSX/GL/GLGSRender.h @@ -84,12 +84,10 @@ public: bool is_intel_vendor; GLGSRender(); - virtual ~GLGSRender(); private: static u32 enable(u32 enable, u32 cap); static u32 enable(u32 enable, u32 cap, u32 index); - void close() override; public: bool load_program(); diff --git a/rpcs3/Emu/RSX/GL/gl_helpers.cpp b/rpcs3/Emu/RSX/GL/gl_helpers.cpp index 9394f03d96..a670ccad83 100644 --- a/rpcs3/Emu/RSX/GL/gl_helpers.cpp +++ b/rpcs3/Emu/RSX/GL/gl_helpers.cpp @@ -70,7 +70,13 @@ namespace gl void fbo::draw_buffers(const std::initializer_list& indexes) const { save_binding_state save(*this); - __glcheck glDrawBuffers((GLsizei)indexes.size(), (const GLenum*)indexes.begin()); + std::vector ids; + ids.reserve(indexes.size()); + + for (auto &index : indexes) + ids.push_back(index.id()); + + __glcheck glDrawBuffers((GLsizei)ids.size(), ids.data()); } void fbo::draw_arrays(draw_mode mode, GLsizei count, GLint first) const diff --git a/rpcs3/Emu/RSX/GL/gl_helpers.h b/rpcs3/Emu/RSX/GL/gl_helpers.h index 0b71d4a60d..326132b14a 100644 --- a/rpcs3/Emu/RSX/GL/gl_helpers.h +++ b/rpcs3/Emu/RSX/GL/gl_helpers.h @@ -1831,6 +1831,21 @@ namespace gl active_texture = 0; } + bool has_location(const std::string &name, int *location = nullptr) + { + int result = glGetUniformLocation(m_program.id(), name.c_str()); + + if (result < 0) + return false; + + locations[name] = result; + + if (location) + *location = result; + + return true; + } + GLint location(const std::string &name) { auto finded = locations.find(name); @@ -1850,16 +1865,21 @@ namespace gl return result; } - int texture(const std::string &name, int active_texture, const gl::texture& texture) + int texture(GLint location, int active_texture, const gl::texture& texture) { glActiveTexture(GL_TEXTURE0 + active_texture); texture.bind(); - (*this)[name] = active_texture; + (*this)[location] = active_texture; return active_texture; } - int texture(const std::string &name, const gl::texture& tex) + int texture(const std::string &name, int active_texture, const gl::texture& texture_) + { + return texture(location(name), active_texture, texture_); + } + + int texture(const std::string &name, const gl::texture& texture_) { int atex; auto finded = locations.find(name); @@ -1873,7 +1893,7 @@ namespace gl atex = active_texture++; } - return texture(name, atex, tex); + return texture(name, atex, texture_); } uniform_t operator[](GLint location) diff --git a/rpcs3/Emu/RSX/GSManager.h b/rpcs3/Emu/RSX/GSManager.h index 7d8a185364..fc6d73e97b 100644 --- a/rpcs3/Emu/RSX/GSManager.h +++ b/rpcs3/Emu/RSX/GSManager.h @@ -1,6 +1,6 @@ #pragma once -struct GSRender; +class GSRender; struct GSInfo { diff --git a/rpcs3/Emu/RSX/GSRender.cpp b/rpcs3/Emu/RSX/GSRender.cpp index 93d3e6f1c4..19408a4010 100644 --- a/rpcs3/Emu/RSX/GSRender.cpp +++ b/rpcs3/Emu/RSX/GSRender.cpp @@ -10,3 +10,58 @@ draw_context_t GSFrameBase::new_context() { return std::shared_ptr(make_context(), [this](void* ctxt) { delete_context(ctxt); }); } + +void GSFrameBase::title_message(const std::wstring& msg) +{ + m_title_message = msg; +} + +GSRender::GSRender(frame_type type) : m_frame(Emu.GetCallbacks().get_gs_frame(type).release()) +{ +} + +GSRender::~GSRender() +{ + m_context = nullptr; + + if (m_frame) + { + m_frame->close(); + } +} + +void GSRender::oninit() +{ + if (m_frame) + { + m_frame->show(); + } +} + +void GSRender::oninit_thread() +{ + if (m_frame) + { + m_context = m_frame->new_context(); + m_frame->set_current(m_context); + } +} + +void GSRender::close() +{ + if (m_frame && m_frame->shown()) + { + m_frame->hide(); + } + + if (joinable()) + { + join(); + } +} + +void GSRender::flip(int buffer) +{ + if (m_frame) + m_frame->flip(m_context); +} \ No newline at end of file diff --git a/rpcs3/Emu/RSX/GSRender.h b/rpcs3/Emu/RSX/GSRender.h index 84f5a7557c..c3c6acc5b3 100644 --- a/rpcs3/Emu/RSX/GSRender.h +++ b/rpcs3/Emu/RSX/GSRender.h @@ -6,6 +6,9 @@ using draw_context_t = std::shared_ptr; class GSFrameBase { +protected: + std::wstring m_title_message; + public: GSFrameBase() = default; GSFrameBase(const GSFrameBase&) = delete; @@ -21,13 +24,34 @@ public: virtual void flip(draw_context_t ctx) = 0; virtual size2i client_size() = 0; + virtual void* handle() const = 0; + void title_message(const std::wstring&); + protected: virtual void delete_context(void* ctx) = 0; virtual void* make_context() = 0; }; -struct GSRender : public rsx::thread +enum class frame_type { - virtual ~GSRender() = default; - virtual void close()=0; + Null, + OpenGL, + DX12 +}; + +class GSRender : public rsx::thread +{ +protected: + GSFrameBase* m_frame; + draw_context_t m_context; + +public: + GSRender(frame_type type); + virtual ~GSRender(); + + void oninit() override; + void oninit_thread() override; + + void close(); + void flip(int buffer) override; }; diff --git a/rpcs3/Emu/RSX/Null/NullGSRender.cpp b/rpcs3/Emu/RSX/Null/NullGSRender.cpp new file mode 100644 index 0000000000..efd06ae11f --- /dev/null +++ b/rpcs3/Emu/RSX/Null/NullGSRender.cpp @@ -0,0 +1,16 @@ +#include "stdafx.h" +#include "NullGSRender.h" +#include "Emu/System.h" + +NullGSRender::NullGSRender() : GSRender(frame_type::Null) +{ +} + +void NullGSRender::onexit_thread() +{ +} + +bool NullGSRender::domethod(u32 cmd, u32 value) +{ + return false; +} diff --git a/rpcs3/Emu/RSX/Null/NullGSRender.h b/rpcs3/Emu/RSX/Null/NullGSRender.h index 53b130eb2c..af1602a6c0 100644 --- a/rpcs3/Emu/RSX/Null/NullGSRender.h +++ b/rpcs3/Emu/RSX/Null/NullGSRender.h @@ -3,29 +3,10 @@ class NullGSRender final : public GSRender { +public: + NullGSRender(); + private: - void oninit() override - { - } - - void oninit_thread() override - { - } - - void onexit_thread() override - { - } - - bool domethod(u32 cmd, u32 value) override - { - return false; - } - - void flip(int buffer) override - { - } - - void close() override - { - } + void onexit_thread() override; + bool domethod(u32 cmd, u32 value) override; }; diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 6f34d86d8d..ac3a92f96e 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -47,13 +47,13 @@ namespace rsx __forceinline void semaphore_acquire(thread* rsx, u32 arg) { //TODO: dma - while (vm::read32(rsx->label_addr + method_registers[NV406E_SEMAPHORE_OFFSET]) != arg) + /*while (vm::read32(rsx->label_addr + method_registers[NV406E_SEMAPHORE_OFFSET]) != arg) { if (Emu.IsStopped()) break; std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } + }*/ } __forceinline void semaphore_release(thread* rsx, u32 arg) @@ -201,6 +201,42 @@ namespace rsx return; } + if (!rsx->vertex_draw_count) + { + bool has_array = false; + + for (int i = 0; i < rsx::limits::vertex_count; ++i) + { + if (rsx->vertex_arrays_info[i].array) + { + has_array = true; + break; + } + } + + if (!has_array) + { + u32 min_count = ~0; + + for (int i = 0; i < rsx::limits::vertex_count; ++i) + { + if (!rsx->vertex_arrays_info[i].size) + continue; + + u32 count = u32(rsx->vertex_arrays[i].size()) / + rsx::get_vertex_type_size(rsx->vertex_arrays_info[i].type) * rsx->vertex_arrays_info[i].size; + + if (count < min_count) + min_count = count; + } + + if (min_count && min_count < ~0) + { + rsx->vertex_draw_count = min_count; + } + } + } + rsx->end(); rsx->vertex_draw_count = 0; } diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index bd266e1080..72ed9a202c 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -32,11 +32,11 @@ namespace rsx u8 _u8[0x10000]; u32 _u32[0x10000 >> 2]; /* - struct + struct alignas(4) { u8 pad[NV4097_SET_TEXTURE_OFFSET - 4]; - struct texture_t + struct alignas(4) texture_t { u32 offset; diff --git a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp index dc1a3e2521..97cf94f5ba 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp @@ -505,12 +505,11 @@ s32 cellGcmSetPrepareFlip(PPUThread& ppu, vm::ptr ctxt, u32 } } - *ctxt->current++ = 0x3fead | (1 << 18); - *ctxt->current++ = id; + u32 command_size = rsx::make_command(ctxt->current, GCM_FLIP_COMMAND, id); if (ctxt.addr() == gcm_info.context_addr) { - vm::get_ref(gcm_info.control_addr).put += 8; + vm::get_ref(gcm_info.control_addr).put += command_size * sizeof(u32); } return id; diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index 1afd964ddc..0c3b730a08 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -11,7 +11,7 @@ struct EmuCallbacks std::function()> get_kb_handler; std::function()> get_mouse_handler; std::function()> get_pad_handler; - std::function()> get_gs_frame; + std::function(enum class frame_type)> get_gs_frame; std::function()> get_msg_dialog; std::function()> get_save_dialog; }; diff --git a/rpcs3/Gui/D3DGSFrame.cpp b/rpcs3/Gui/D3DGSFrame.cpp deleted file mode 100644 index f4327da252..0000000000 --- a/rpcs3/Gui/D3DGSFrame.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include "stdafx_gui.h" -#if defined(DX12_SUPPORT) -#include "Emu/Memory/Memory.h" -#include "Emu/System.h" -#include "D3DGSFrame.h" -#include "Utilities/Timer.h" - -D3DGSFrame::D3DGSFrame() - : GSFrame(nullptr, "GSFrame[DirectX 12]") - , m_frames(0) -{ - SetIcon(wxICON(frame_icon)); - canvas = new wxWindow(this, wxID_ANY); - canvas->SetSize(GetClientSize()); - - canvas->Bind(wxEVT_LEFT_DCLICK, &GSFrame::OnLeftDclick, this); -} - -D3DGSFrame::~D3DGSFrame() -{ -} - -void D3DGSFrame::Close() -{ - GSFrame::Close(); -} - -bool D3DGSFrame::IsShown() -{ - return GSFrame::IsShown(); -} - -void D3DGSFrame::Hide() -{ - GSFrame::Hide(); -} - -void D3DGSFrame::Show() -{ - GSFrame::Show(); -} - -void* D3DGSFrame::GetNewContext() -{ - return nullptr;//new wxGLContext(GetCanvas()); -} - -void D3DGSFrame::SetCurrent(void* ctx) -{ -// GetCanvas()->SetCurrent(*(wxGLContext*)ctx); -} - -void D3DGSFrame::DeleteContext(void* ctx) -{ -// delete (wxGLContext*)ctx; -} - -void D3DGSFrame::Flip(void* context) -{ - if (!canvas) return; -// canvas->SetCurrent(*(wxGLContext*)context); - - static Timer fps_t; -// canvas->SwapBuffers(); - m_frames++; - - const std::string sub_title = Emu.GetTitle() + (Emu.GetTitleID().length() ? " [" + Emu.GetTitleID() + "] | " : " | ") + " | "; - - if (fps_t.GetElapsedTimeInSec() >= 0.5) - { - // can freeze on exit - SetTitle(wxString(sub_title.c_str(), wxConvUTF8) + wxString::Format("FPS: %.2f", (double)m_frames / fps_t.GetElapsedTimeInSec())); - m_frames = 0; - fps_t.Start(); - } -} - -void D3DGSFrame::OnSize(wxSizeEvent& event) -{ - if (canvas) canvas->SetSize(GetClientSize()); - event.Skip(); -} - -void D3DGSFrame::SetViewport(int x, int y, u32 w, u32 h) -{ - /* - //ConLog.Warning("SetViewport(x=%d, y=%d, w=%d, h=%d)", x, y, w, h); - - const wxSize client = GetClientSize(); - const wxSize viewport = AspectRatio(client, wxSize(w, h)); - - const int vx = (client.GetX() - viewport.GetX()) / 2; - const int vy = (client.GetY() - viewport.GetY()) / 2; - - glViewport(vx + x, vy + y, viewport.GetWidth(), viewport.GetHeight()); - */ -} - -HWND D3DGSFrame::getHandle() const -{ - return canvas->GetHandle(); -} -#endif \ No newline at end of file diff --git a/rpcs3/Gui/D3DGSFrame.h b/rpcs3/Gui/D3DGSFrame.h deleted file mode 100644 index 47de197d0a..0000000000 --- a/rpcs3/Gui/D3DGSFrame.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#if defined(DX12_SUPPORT) -#include "Emu/RSX/D3D12/D3D12GSRender.h" -#include "Gui/GSFrame.h" -#include "wx/window.h" - -struct D3DGSFrame : public GSFrame, public GSFrameBase2 -{ - wxWindow* canvas; - u32 m_frames; - - D3DGSFrame(); - ~D3DGSFrame(); - - virtual void Close() override; - - virtual bool IsShown() override; - virtual void Hide() override; - virtual void Show() override; - - virtual void* GetNewContext() override; - virtual void SetCurrent(void* ctx) override; - virtual void DeleteContext(void* ctx) override; - virtual void Flip(void* context) override; - - wxWindow* GetCanvas() const { return canvas; } - - virtual void SetViewport(int x, int y, u32 w, u32 h) override; - virtual HWND getHandle() const override; - -private: - virtual void OnSize(wxSizeEvent& event); -}; - -#endif \ No newline at end of file diff --git a/rpcs3/Gui/GLGSFrame.cpp b/rpcs3/Gui/GLGSFrame.cpp index 0e48b45e49..67e88bccae 100644 --- a/rpcs3/Gui/GLGSFrame.cpp +++ b/rpcs3/Gui/GLGSFrame.cpp @@ -1,54 +1,22 @@ #include "stdafx_gui.h" -#include "Utilities/Log.h" -#include "Emu/Memory/Memory.h" -#include "Emu/System.h" #include "GLGSFrame.h" -#include "D3DGSFrame.h" -#include "Utilities/Timer.h" -#ifndef _WIN32 -#include "frame_icon.xpm" -#endif - -GLGSFrame::GLGSFrame() - : GSFrame(nullptr, "GSFrame[OpenGL]") - , m_frames(0) +GLGSFrame::GLGSFrame() : GSFrame("OpenGL") { - SetIcon(wxICON(frame_icon)); - canvas = new wxGLCanvas(this, wxID_ANY, NULL); - canvas->SetSize(GetClientSize()); + m_canvas = new wxGLCanvas(this, wxID_ANY, NULL); + m_canvas->SetSize(GetClientSize()); - canvas->Bind(wxEVT_LEFT_DCLICK, &GSFrame::OnLeftDclick, this); -} - -void GLGSFrame::close() -{ - GSFrame::Close(); -} - -bool GLGSFrame::shown() -{ - return GSFrame::IsShown(); -} - -void GLGSFrame::hide() -{ - GSFrame::Hide(); -} - -void GLGSFrame::show() -{ - GSFrame::Show(); + m_canvas->Bind(wxEVT_LEFT_DCLICK, &GSFrame::OnLeftDclick, this); } void* GLGSFrame::make_context() { - return new wxGLContext(GetCanvas()); + return new wxGLContext(m_canvas); } void GLGSFrame::set_current(draw_context_t ctx) { - GetCanvas()->SetCurrent(*(wxGLContext*)ctx.get()); + m_canvas->SetCurrent(*(wxGLContext*)ctx.get()); } void GLGSFrame::delete_context(void* ctx) @@ -58,47 +26,18 @@ void GLGSFrame::delete_context(void* ctx) void GLGSFrame::flip(draw_context_t context) { - if (!canvas) return; - canvas->SetCurrent(*(wxGLContext*)context.get()); + GSFrame::flip(context); - static Timer fps_t; - canvas->SwapBuffers(); - m_frames++; + if (!m_canvas) return; - const std::string sub_title = Emu.GetTitle() + (Emu.GetTitleID().length() ? " [" + Emu.GetTitleID() + "] | " : " | "); - - if (fps_t.GetElapsedTimeInSec() >= 0.5) - { - // can freeze on exit - SetTitle(wxString(sub_title.c_str(), wxConvUTF8) + wxString::Format("FPS: %.2f", (double)m_frames / fps_t.GetElapsedTimeInSec())); - m_frames = 0; - fps_t.Start(); - } -} - -size2i GLGSFrame::client_size() -{ - wxSize size = GetClientSize(); - return{ size.GetWidth(), size.GetHeight() }; + m_canvas->SetCurrent(*(wxGLContext*)context.get()); + m_canvas->SwapBuffers(); } void GLGSFrame::OnSize(wxSizeEvent& event) { - if (canvas) canvas->SetSize(GetClientSize()); + if (m_canvas) + m_canvas->SetSize(GetClientSize()); + event.Skip(); -} - -void GLGSFrame::SetViewport(int x, int y, u32 w, u32 h) -{ - /* - //ConLog.Warning("SetViewport(x=%d, y=%d, w=%d, h=%d)", x, y, w, h); - - const wxSize client = GetClientSize(); - const wxSize viewport = AspectRatio(client, wxSize(w, h)); - - const int vx = (client.GetX() - viewport.GetX()) / 2; - const int vy = (client.GetY() - viewport.GetY()) / 2; - - glViewport(vx + x, vy + y, viewport.GetWidth(), viewport.GetHeight()); - */ } \ No newline at end of file diff --git a/rpcs3/Gui/GLGSFrame.h b/rpcs3/Gui/GLGSFrame.h index 9fa7ce6054..c73b47e10a 100644 --- a/rpcs3/Gui/GLGSFrame.h +++ b/rpcs3/Gui/GLGSFrame.h @@ -1,30 +1,18 @@ #pragma once -#include "Emu/RSX/GL/GLGSRender.h" #include "Gui/GSFrame.h" #include "wx/glcanvas.h" -struct GLGSFrame : public GSFrame, public GSFrameBase +class GLGSFrame : public GSFrame { - wxGLCanvas* canvas; - u32 m_frames; + wxGLCanvas* m_canvas; +public: GLGSFrame(); - void close() override; - - bool shown() override; - void hide() override; - void show() override; - void* make_context() override; void set_current(draw_context_t context) override; void delete_context(void* context) override; void flip(draw_context_t context) override; - size2i client_size() override; - - wxGLCanvas* GetCanvas() const { return canvas; } - - virtual void SetViewport(int x, int y, u32 w, u32 h) override; private: virtual void OnSize(wxSizeEvent& event); diff --git a/rpcs3/Gui/GSFrame.cpp b/rpcs3/Gui/GSFrame.cpp index c34509bb3e..00f5908740 100644 --- a/rpcs3/Gui/GSFrame.cpp +++ b/rpcs3/Gui/GSFrame.cpp @@ -3,32 +3,21 @@ #include "Emu/System.h" #include "Emu/SysCalls/Modules/cellVideoOut.h" #include "rpcs3.h" +#include "Utilities/Timer.h" + +#ifndef _WIN32 +#include "frame_icon.xpm" +#endif BEGIN_EVENT_TABLE(GSFrame, wxFrame) EVT_PAINT(GSFrame::OnPaint) EVT_SIZE(GSFrame::OnSize) END_EVENT_TABLE() -wxSize AspectRatio(wxSize rs, const wxSize as) +GSFrame::GSFrame(const wxString& title) : wxFrame(nullptr, wxID_ANY, "GSFrame[" + title + "]") { - const double aq = (double)as.x / as.y; - const double rq = (double)rs.x / rs.y; - const double q = aq / rq; + SetIcon(wxICON(frame_icon)); - if (q > 1.0) - { - rs.y /= q; - } - else if (q < 1.0) - { - rs.x *= q; - } - - return rs; -} - -GSFrame::GSFrame(wxWindow* parent, const wxString& title) : wxFrame(parent, wxID_ANY, title) -{ CellVideoOutResolution res = ResolutionTable[ResolutionIdToNum(Ini.GSResolution.GetValue())]; SetClientSize(res.width, res.height); wxGetApp().Bind(wxEVT_KEY_DOWN, &GSFrame::OnKeyDown, this); @@ -45,19 +34,6 @@ void GSFrame::OnClose(wxCloseEvent& event) Emu.Stop(); } -/* -void GSFrame::OnSize(wxSizeEvent&) -{ -const wxSize client = GetClientSize(); -const wxSize viewport = AspectRatio(client, m_size); - -const int x = (client.GetX() - viewport.GetX()) / 2; -const int y = (client.GetY() - viewport.GetY()) / 2; - -SetViewport(wxPoint(x, y), viewport); -} -*/ - void GSFrame::OnKeyDown(wxKeyEvent& event) { switch (event.GetKeyCode()) @@ -73,13 +49,72 @@ void GSFrame::OnFullScreen() ShowFullScreen(!IsFullScreen()); } - -/* -void GSFrame::SetSize(int width, int height) +void GSFrame::close() { -m_size.SetWidth(width); -m_size.SetHeight(height); -//wxFrame::SetSize(width, height); -OnSize(wxSizeEvent()); + wxFrame::Close(); +} + +bool GSFrame::shown() +{ + return wxFrame::IsShown(); +} + +void GSFrame::hide() +{ + wxFrame::Hide(); +} + +void GSFrame::show() +{ + wxFrame::Show(); +} + +void* GSFrame::handle() const +{ + return GetHandle(); +} + +void* GSFrame::make_context() +{ + return nullptr; +} + +void GSFrame::set_current(draw_context_t ctx) +{ +} + +void GSFrame::delete_context(void* ctx) +{ +} + +size2i GSFrame::client_size() +{ + wxSize size = GetClientSize(); + return{ size.GetWidth(), size.GetHeight() }; +} + +void GSFrame::flip(draw_context_t) +{ + ++m_frames; + + static Timer fps_t; + + if (fps_t.GetElapsedTimeInSec() >= 0.5) + { + std::string title = fmt::format("FPS: %.2f", (double)m_frames / fps_t.GetElapsedTimeInSec()); + + if (!m_title_message.empty()) + title += " | " + m_title_message; + + if (!Emu.GetTitle().empty()) + title += " | " + Emu.GetTitle(); + + if (!Emu.GetTitleID().empty()) + title += " | [" + Emu.GetTitleID() + "]"; + + // can freeze on exit + SetTitle(wxString(title.c_str(), wxConvUTF8)); + m_frames = 0; + fps_t.Start(); + } } -*/ diff --git a/rpcs3/Gui/GSFrame.h b/rpcs3/Gui/GSFrame.h index 83601a00cf..01aeea0130 100644 --- a/rpcs3/Gui/GSFrame.h +++ b/rpcs3/Gui/GSFrame.h @@ -1,21 +1,34 @@ #pragma once +#include "Emu/RSX/GSRender.h" -wxSize AspectRatio(wxSize rs, const wxSize as); - -class GSFrame : public wxFrame +class GSFrame : public wxFrame, public GSFrameBase { -protected: - GSFrame(wxWindow* parent, const wxString& title); + u64 m_frames; - virtual void SetViewport(int x, int y, u32 w, u32 h) {} +public: + GSFrame(const wxString& title); + +protected: virtual void OnPaint(wxPaintEvent& event); virtual void OnClose(wxCloseEvent& event); - //virtual void OnSize(wxSizeEvent&); - void OnKeyDown(wxKeyEvent& event); void OnFullScreen(); + void close() override; + + bool shown() override; + void hide() override; + void show() override; + + void* handle() const override; + + void* make_context() override; + void set_current(draw_context_t context) override; + void delete_context(void* context) override; + void flip(draw_context_t context) override; + size2i client_size() override; + public: void OnLeftDclick(wxMouseEvent&) { diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index e37a5a3def..6f900dbdbc 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -75,6 +75,7 @@ + diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index e0b961363d..4860f99fe3 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -992,6 +992,9 @@ Emu\GPU\RSX\GL + + Emu\GPU\RSX\Null + diff --git a/rpcs3/rpcs3.cpp b/rpcs3/rpcs3.cpp index e0e8865b0d..5751c3a0d7 100644 --- a/rpcs3/rpcs3.cpp +++ b/rpcs3/rpcs3.cpp @@ -26,7 +26,6 @@ #include "Gui/SaveDataDialog.h" #include "Gui/GLGSFrame.h" -#include "Gui/D3DGSFrame.h" #include #ifdef _WIN32 @@ -112,18 +111,20 @@ bool Rpcs3App::OnInit() } }; - callbacks.get_gs_frame = []() -> std::unique_ptr + callbacks.get_gs_frame = [](frame_type type) -> std::unique_ptr { - return std::make_unique(); - }; + switch (type) + { + case frame_type::OpenGL: + return std::make_unique(); - // TODO: unify with get_gs_frame callback -#if defined(DX12_SUPPORT) - SetGetD3DGSFrameCallback([]() ->GSFrameBase2* - { - return new D3DGSFrame(); - }); -#endif + case frame_type::DX12: + return std::make_unique("DirectX 12"); + + case frame_type::Null: + return std::make_unique("Null"); + } + }; callbacks.get_msg_dialog = []() -> std::unique_ptr { diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index 271a77b197..daf11368be 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -511,7 +511,6 @@ - @@ -561,7 +560,6 @@ - diff --git a/rpcs3/rpcs3.vcxproj.filters b/rpcs3/rpcs3.vcxproj.filters index b97b3b1f86..14de4716da 100644 --- a/rpcs3/rpcs3.vcxproj.filters +++ b/rpcs3/rpcs3.vcxproj.filters @@ -102,9 +102,6 @@ Gui - - Gui - Gui @@ -216,9 +213,6 @@ Gui - - Gui - Gui