mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-12 13:13:43 +00:00
d3d12: Start implementation
This commit is contained in:
parent
d10c44ed3a
commit
976d707596
599
rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp
Normal file
599
rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp
Normal file
@ -0,0 +1,599 @@
|
||||
#include "stdafx.h"
|
||||
#include "D3D12GSRender.h"
|
||||
#include <wrl/client.h>
|
||||
#include <dxgi1_4.h>
|
||||
|
||||
static void check(HRESULT hr)
|
||||
{
|
||||
if (hr != 0)
|
||||
abort();
|
||||
}
|
||||
|
||||
D3D12GSRender::D3D12GSRender()
|
||||
: GSRender()
|
||||
{
|
||||
// Enable d3d debug layer
|
||||
Microsoft::WRL::ComPtr<ID3D12Debug> debugInterface;
|
||||
D3D12GetDebugInterface(IID_PPV_ARGS(&debugInterface));
|
||||
debugInterface->EnableDebugLayer();
|
||||
|
||||
// Create adapter
|
||||
Microsoft::WRL::ComPtr<IDXGIFactory4> dxgiFactory;
|
||||
check(CreateDXGIFactory(IID_PPV_ARGS(&dxgiFactory)));
|
||||
IDXGIAdapter* warpAdapter;
|
||||
check(dxgiFactory->EnumWarpAdapter(IID_PPV_ARGS(&warpAdapter)));
|
||||
check(D3D12CreateDevice(warpAdapter, D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_device)));
|
||||
|
||||
// Queues
|
||||
D3D12_COMMAND_QUEUE_DESC copyQueueDesc = {}, graphicQueueDesc = {};
|
||||
copyQueueDesc.Type = D3D12_COMMAND_LIST_TYPE_COPY;
|
||||
graphicQueueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
|
||||
check(m_device->CreateCommandQueue(©QueueDesc, IID_PPV_ARGS(&m_commandQueueCopy)));
|
||||
check(m_device->CreateCommandQueue(&graphicQueueDesc, IID_PPV_ARGS(&m_commandQueueGraphic)));
|
||||
}
|
||||
|
||||
D3D12GSRender::~D3D12GSRender()
|
||||
{
|
||||
// NOTE: Should be released only if no command are in flight !
|
||||
m_commandQueueGraphic->Release();
|
||||
m_commandQueueCopy->Release();
|
||||
m_device->Release();
|
||||
}
|
||||
|
||||
void D3D12GSRender::Close()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void D3D12GSRender::InitDrawBuffers()
|
||||
{
|
||||
// if (!m_fbo.IsCreated() || RSXThread::m_width != last_width || RSXThread::m_height != last_height || last_depth_format != m_surface_depth_format)
|
||||
{
|
||||
/*
|
||||
LOG_WARNING(RSX, "New FBO (%dx%d)", RSXThread::m_width, RSXThread::m_height);
|
||||
last_width = RSXThread::m_width;
|
||||
last_height = RSXThread::m_height;
|
||||
last_depth_format = m_surface_depth_format;
|
||||
|
||||
m_fbo.Create();
|
||||
checkForGlError("m_fbo.Create");
|
||||
m_fbo.Bind();
|
||||
|
||||
m_rbo.Create(4 + 1);
|
||||
checkForGlError("m_rbo.Create");
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
m_rbo.Bind(i);
|
||||
m_rbo.Storage(GL_RGBA, RSXThread::m_width, RSXThread::m_height);
|
||||
checkForGlError("m_rbo.Storage(GL_RGBA)");
|
||||
}
|
||||
|
||||
m_rbo.Bind(4);
|
||||
|
||||
switch (m_surface_depth_format)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
// case 0 found in BLJM60410-[Suzukaze no Melt - Days in the Sanctuary]
|
||||
// [E : RSXThread]: Bad depth format! (0)
|
||||
// [E : RSXThread]: glEnable: opengl error 0x0506
|
||||
// [E : RSXThread]: glDrawArrays: opengl error 0x0506
|
||||
m_rbo.Storage(GL_DEPTH_COMPONENT, RSXThread::m_width, RSXThread::m_height);
|
||||
checkForGlError("m_rbo.Storage(GL_DEPTH_COMPONENT)");
|
||||
break;
|
||||
}
|
||||
|
||||
case CELL_GCM_SURFACE_Z16:
|
||||
{
|
||||
m_rbo.Storage(GL_DEPTH_COMPONENT16, RSXThread::m_width, RSXThread::m_height);
|
||||
checkForGlError("m_rbo.Storage(GL_DEPTH_COMPONENT16)");
|
||||
|
||||
m_fbo.Renderbuffer(GL_DEPTH_ATTACHMENT, m_rbo.GetId(4));
|
||||
checkForGlError("m_fbo.Renderbuffer(GL_DEPTH_ATTACHMENT)");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case CELL_GCM_SURFACE_Z24S8:
|
||||
{
|
||||
m_rbo.Storage(GL_DEPTH24_STENCIL8, RSXThread::m_width, RSXThread::m_height);
|
||||
checkForGlError("m_rbo.Storage(GL_DEPTH24_STENCIL8)");
|
||||
|
||||
m_fbo.Renderbuffer(GL_DEPTH_ATTACHMENT, m_rbo.GetId(4));
|
||||
checkForGlError("m_fbo.Renderbuffer(GL_DEPTH_ATTACHMENT)");
|
||||
|
||||
m_fbo.Renderbuffer(GL_STENCIL_ATTACHMENT, m_rbo.GetId(4));
|
||||
checkForGlError("m_fbo.Renderbuffer(GL_STENCIL_ATTACHMENT)");
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
{
|
||||
LOG_ERROR(RSX, "Bad depth format! (%d)", m_surface_depth_format);
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
m_fbo.Renderbuffer(GL_COLOR_ATTACHMENT0 + i, m_rbo.GetId(i));
|
||||
checkForGlError(fmt::Format("m_fbo.Renderbuffer(GL_COLOR_ATTACHMENT%d)", i));
|
||||
}
|
||||
*/
|
||||
//m_fbo.Renderbuffer(GL_DEPTH_ATTACHMENT, m_rbo.GetId(4));
|
||||
//checkForGlError("m_fbo.Renderbuffer(GL_DEPTH_ATTACHMENT)");
|
||||
|
||||
//if (m_surface_depth_format == 2)
|
||||
//{
|
||||
// m_fbo.Renderbuffer(GL_STENCIL_ATTACHMENT, m_rbo.GetId(4));
|
||||
// checkForGlError("m_fbo.Renderbuffer(GL_STENCIL_ATTACHMENT)");
|
||||
//}
|
||||
}
|
||||
/*
|
||||
if (!m_set_surface_clip_horizontal)
|
||||
{
|
||||
m_surface_clip_x = 0;
|
||||
m_surface_clip_w = RSXThread::m_width;
|
||||
}
|
||||
|
||||
if (!m_set_surface_clip_vertical)
|
||||
{
|
||||
m_surface_clip_y = 0;
|
||||
m_surface_clip_h = RSXThread::m_height;
|
||||
}
|
||||
|
||||
m_fbo.Bind();
|
||||
|
||||
static const GLenum draw_buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
|
||||
|
||||
switch (m_surface_color_target)
|
||||
{
|
||||
case CELL_GCM_SURFACE_TARGET_NONE: break;
|
||||
|
||||
case CELL_GCM_SURFACE_TARGET_0:
|
||||
{
|
||||
glDrawBuffer(draw_buffers[0]);
|
||||
checkForGlError("glDrawBuffer(0)");
|
||||
break;
|
||||
}
|
||||
|
||||
case CELL_GCM_SURFACE_TARGET_1:
|
||||
{
|
||||
glDrawBuffer(draw_buffers[1]);
|
||||
checkForGlError("glDrawBuffer(1)");
|
||||
break;
|
||||
}
|
||||
|
||||
case CELL_GCM_SURFACE_TARGET_MRT1:
|
||||
{
|
||||
glDrawBuffers(2, draw_buffers);
|
||||
checkForGlError("glDrawBuffers(2)");
|
||||
break;
|
||||
}
|
||||
|
||||
case CELL_GCM_SURFACE_TARGET_MRT2:
|
||||
{
|
||||
glDrawBuffers(3, draw_buffers);
|
||||
checkForGlError("glDrawBuffers(3)");
|
||||
break;
|
||||
}
|
||||
|
||||
case CELL_GCM_SURFACE_TARGET_MRT3:
|
||||
{
|
||||
glDrawBuffers(4, draw_buffers);
|
||||
checkForGlError("glDrawBuffers(4)");
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
LOG_ERROR(RSX, "Bad surface color target: %d", m_surface_color_target);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (m_read_buffer)
|
||||
{
|
||||
u32 format = GL_BGRA;
|
||||
CellGcmDisplayInfo* buffers = vm::get_ptr<CellGcmDisplayInfo>(m_gcm_buffers_addr);
|
||||
u32 addr = GetAddress(buffers[m_gcm_current_buffer].offset, CELL_GCM_LOCATION_LOCAL);
|
||||
u32 width = buffers[m_gcm_current_buffer].width;
|
||||
u32 height = buffers[m_gcm_current_buffer].height;
|
||||
glDrawPixels(width, height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, vm::get_ptr(addr));
|
||||
}*/
|
||||
}
|
||||
|
||||
void D3D12GSRender::OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
void D3D12GSRender::OnInitThread()
|
||||
{
|
||||
}
|
||||
|
||||
void D3D12GSRender::OnExitThread()
|
||||
{
|
||||
}
|
||||
|
||||
void D3D12GSRender::OnReset()
|
||||
{
|
||||
}
|
||||
|
||||
void D3D12GSRender::ExecCMD(u32 cmd)
|
||||
{
|
||||
}
|
||||
|
||||
void D3D12GSRender::ExecCMD()
|
||||
{
|
||||
ID3D12CommandAllocator *commandAllocator;
|
||||
m_device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&commandAllocator));
|
||||
ID3D12CommandList *commandList;
|
||||
m_device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, commandAllocator, nullptr, IID_PPV_ARGS(&commandList));
|
||||
|
||||
|
||||
//return;
|
||||
/* if (!LoadProgram())
|
||||
{
|
||||
LOG_ERROR(RSX, "LoadProgram failed.");
|
||||
Emu.Pause();
|
||||
return;
|
||||
}
|
||||
|
||||
InitDrawBuffers();
|
||||
|
||||
if (m_set_color_mask)
|
||||
{
|
||||
glColorMask(m_color_mask_r, m_color_mask_g, m_color_mask_b, m_color_mask_a);
|
||||
checkForGlError("glColorMask");
|
||||
}
|
||||
|
||||
if (!m_indexed_array.m_count && !m_draw_array_count)
|
||||
{
|
||||
u32 min_vertex_size = ~0;
|
||||
for (auto &i : m_vertex_data)
|
||||
{
|
||||
if (!i.size)
|
||||
continue;
|
||||
|
||||
u32 vertex_size = i.data.size() / (i.size * i.GetTypeSize());
|
||||
|
||||
if (min_vertex_size > vertex_size)
|
||||
min_vertex_size = vertex_size;
|
||||
}
|
||||
|
||||
m_draw_array_count = min_vertex_size;
|
||||
m_draw_array_first = 0;
|
||||
}
|
||||
|
||||
Enable(m_set_depth_test, GL_DEPTH_TEST);
|
||||
Enable(m_set_alpha_test, GL_ALPHA_TEST);
|
||||
Enable(m_set_blend || m_set_blend_mrt1 || m_set_blend_mrt2 || m_set_blend_mrt3, GL_BLEND);
|
||||
Enable(m_set_scissor_horizontal && m_set_scissor_vertical, GL_SCISSOR_TEST);
|
||||
Enable(m_set_logic_op, GL_LOGIC_OP);
|
||||
Enable(m_set_cull_face, GL_CULL_FACE);
|
||||
Enable(m_set_dither, GL_DITHER);
|
||||
Enable(m_set_stencil_test, GL_STENCIL_TEST);
|
||||
Enable(m_set_line_smooth, GL_LINE_SMOOTH);
|
||||
Enable(m_set_poly_smooth, GL_POLYGON_SMOOTH);
|
||||
Enable(m_set_point_sprite_control, GL_POINT_SPRITE);
|
||||
Enable(m_set_specular, GL_LIGHTING);
|
||||
Enable(m_set_poly_offset_fill, GL_POLYGON_OFFSET_FILL);
|
||||
Enable(m_set_poly_offset_line, GL_POLYGON_OFFSET_LINE);
|
||||
Enable(m_set_poly_offset_point, GL_POLYGON_OFFSET_POINT);
|
||||
Enable(m_set_restart_index, GL_PRIMITIVE_RESTART);
|
||||
Enable(m_set_line_stipple, GL_LINE_STIPPLE);
|
||||
Enable(m_set_polygon_stipple, GL_POLYGON_STIPPLE);
|
||||
|
||||
if (!is_intel_vendor)
|
||||
{
|
||||
Enable(m_set_depth_bounds_test, GL_DEPTH_BOUNDS_TEST_EXT);
|
||||
}
|
||||
|
||||
if (m_set_clip_plane)
|
||||
{
|
||||
Enable(m_clip_plane_0, GL_CLIP_PLANE0);
|
||||
Enable(m_clip_plane_1, GL_CLIP_PLANE1);
|
||||
Enable(m_clip_plane_2, GL_CLIP_PLANE2);
|
||||
Enable(m_clip_plane_3, GL_CLIP_PLANE3);
|
||||
Enable(m_clip_plane_4, GL_CLIP_PLANE4);
|
||||
Enable(m_clip_plane_5, GL_CLIP_PLANE5);
|
||||
|
||||
checkForGlError("m_set_clip_plane");
|
||||
}
|
||||
|
||||
checkForGlError("glEnable");
|
||||
|
||||
if (m_set_front_polygon_mode)
|
||||
{
|
||||
glPolygonMode(GL_FRONT, m_front_polygon_mode);
|
||||
checkForGlError("glPolygonMode(Front)");
|
||||
}
|
||||
|
||||
if (m_set_back_polygon_mode)
|
||||
{
|
||||
glPolygonMode(GL_BACK, m_back_polygon_mode);
|
||||
checkForGlError("glPolygonMode(Back)");
|
||||
}
|
||||
|
||||
if (m_set_point_size)
|
||||
{
|
||||
glPointSize(m_point_size);
|
||||
checkForGlError("glPointSize");
|
||||
}
|
||||
|
||||
if (m_set_poly_offset_mode)
|
||||
{
|
||||
glPolygonOffset(m_poly_offset_scale_factor, m_poly_offset_bias);
|
||||
checkForGlError("glPolygonOffset");
|
||||
}
|
||||
|
||||
if (m_set_logic_op)
|
||||
{
|
||||
glLogicOp(m_logic_op);
|
||||
checkForGlError("glLogicOp");
|
||||
}
|
||||
|
||||
if (m_set_scissor_horizontal && m_set_scissor_vertical)
|
||||
{
|
||||
glScissor(m_scissor_x, m_scissor_y, m_scissor_w, m_scissor_h);
|
||||
checkForGlError("glScissor");
|
||||
}
|
||||
|
||||
if (m_set_two_sided_stencil_test_enable)
|
||||
{
|
||||
if (m_set_stencil_fail && m_set_stencil_zfail && m_set_stencil_zpass)
|
||||
{
|
||||
glStencilOpSeparate(GL_FRONT, m_stencil_fail, m_stencil_zfail, m_stencil_zpass);
|
||||
checkForGlError("glStencilOpSeparate");
|
||||
}
|
||||
|
||||
if (m_set_stencil_mask)
|
||||
{
|
||||
glStencilMaskSeparate(GL_FRONT, m_stencil_mask);
|
||||
checkForGlError("glStencilMaskSeparate");
|
||||
}
|
||||
|
||||
if (m_set_stencil_func && m_set_stencil_func_ref && m_set_stencil_func_mask)
|
||||
{
|
||||
glStencilFuncSeparate(GL_FRONT, m_stencil_func, m_stencil_func_ref, m_stencil_func_mask);
|
||||
checkForGlError("glStencilFuncSeparate");
|
||||
}
|
||||
|
||||
if (m_set_back_stencil_fail && m_set_back_stencil_zfail && m_set_back_stencil_zpass)
|
||||
{
|
||||
glStencilOpSeparate(GL_BACK, m_back_stencil_fail, m_back_stencil_zfail, m_back_stencil_zpass);
|
||||
checkForGlError("glStencilOpSeparate(GL_BACK)");
|
||||
}
|
||||
|
||||
if (m_set_back_stencil_mask)
|
||||
{
|
||||
glStencilMaskSeparate(GL_BACK, m_back_stencil_mask);
|
||||
checkForGlError("glStencilMaskSeparate(GL_BACK)");
|
||||
}
|
||||
|
||||
if (m_set_back_stencil_func && m_set_back_stencil_func_ref && m_set_back_stencil_func_mask)
|
||||
{
|
||||
glStencilFuncSeparate(GL_BACK, m_back_stencil_func, m_back_stencil_func_ref, m_back_stencil_func_mask);
|
||||
checkForGlError("glStencilFuncSeparate(GL_BACK)");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_set_stencil_fail && m_set_stencil_zfail && m_set_stencil_zpass)
|
||||
{
|
||||
glStencilOp(m_stencil_fail, m_stencil_zfail, m_stencil_zpass);
|
||||
checkForGlError("glStencilOp");
|
||||
}
|
||||
|
||||
if (m_set_stencil_mask)
|
||||
{
|
||||
glStencilMask(m_stencil_mask);
|
||||
checkForGlError("glStencilMask");
|
||||
}
|
||||
|
||||
if (m_set_stencil_func && m_set_stencil_func_ref && m_set_stencil_func_mask)
|
||||
{
|
||||
glStencilFunc(m_stencil_func, m_stencil_func_ref, m_stencil_func_mask);
|
||||
checkForGlError("glStencilFunc");
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Use other glLightModel functions?
|
||||
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, m_set_two_side_light_enable ? GL_TRUE : GL_FALSE);
|
||||
checkForGlError("glLightModeli");
|
||||
|
||||
if (m_set_shade_mode)
|
||||
{
|
||||
glShadeModel(m_shade_mode);
|
||||
checkForGlError("glShadeModel");
|
||||
}
|
||||
|
||||
if (m_set_depth_mask)
|
||||
{
|
||||
glDepthMask(m_depth_mask);
|
||||
checkForGlError("glDepthMask");
|
||||
}
|
||||
|
||||
if (m_set_depth_func)
|
||||
{
|
||||
glDepthFunc(m_depth_func);
|
||||
checkForGlError("glDepthFunc");
|
||||
}
|
||||
|
||||
if (m_set_depth_bounds && !is_intel_vendor)
|
||||
{
|
||||
glDepthBoundsEXT(m_depth_bounds_min, m_depth_bounds_max);
|
||||
checkForGlError("glDepthBounds");
|
||||
}
|
||||
|
||||
if (m_set_clip)
|
||||
{
|
||||
glDepthRangef(m_clip_min, m_clip_max);
|
||||
checkForGlError("glDepthRangef");
|
||||
}
|
||||
|
||||
if (m_set_line_width)
|
||||
{
|
||||
glLineWidth(m_line_width);
|
||||
checkForGlError("glLineWidth");
|
||||
}
|
||||
|
||||
if (m_set_line_stipple)
|
||||
{
|
||||
glLineStipple(m_line_stipple_factor, m_line_stipple_pattern);
|
||||
checkForGlError("glLineStipple");
|
||||
}
|
||||
|
||||
if (m_set_polygon_stipple)
|
||||
{
|
||||
glPolygonStipple((const GLubyte*)m_polygon_stipple_pattern);
|
||||
checkForGlError("glPolygonStipple");
|
||||
}
|
||||
|
||||
if (m_set_blend_equation)
|
||||
{
|
||||
glBlendEquationSeparate(m_blend_equation_rgb, m_blend_equation_alpha);
|
||||
checkForGlError("glBlendEquationSeparate");
|
||||
}
|
||||
|
||||
if (m_set_blend_sfactor && m_set_blend_dfactor)
|
||||
{
|
||||
glBlendFuncSeparate(m_blend_sfactor_rgb, m_blend_dfactor_rgb, m_blend_sfactor_alpha, m_blend_dfactor_alpha);
|
||||
checkForGlError("glBlendFuncSeparate");
|
||||
}
|
||||
|
||||
if (m_set_blend_color)
|
||||
{
|
||||
glBlendColor(m_blend_color_r, m_blend_color_g, m_blend_color_b, m_blend_color_a);
|
||||
checkForGlError("glBlendColor");
|
||||
}
|
||||
|
||||
if (m_set_cull_face)
|
||||
{
|
||||
glCullFace(m_cull_face);
|
||||
checkForGlError("glCullFace");
|
||||
}
|
||||
|
||||
if (m_set_front_face)
|
||||
{
|
||||
glFrontFace(m_front_face);
|
||||
checkForGlError("glFrontFace");
|
||||
}
|
||||
|
||||
if (m_set_alpha_func && m_set_alpha_ref)
|
||||
{
|
||||
glAlphaFunc(m_alpha_func, m_alpha_ref);
|
||||
checkForGlError("glAlphaFunc");
|
||||
}
|
||||
|
||||
if (m_set_fog_mode)
|
||||
{
|
||||
glFogi(GL_FOG_MODE, m_fog_mode);
|
||||
checkForGlError("glFogi(GL_FOG_MODE)");
|
||||
}
|
||||
|
||||
if (m_set_fog_params)
|
||||
{
|
||||
glFogf(GL_FOG_START, m_fog_param0);
|
||||
checkForGlError("glFogf(GL_FOG_START)");
|
||||
glFogf(GL_FOG_END, m_fog_param1);
|
||||
checkForGlError("glFogf(GL_FOG_END)");
|
||||
}
|
||||
|
||||
if (m_set_restart_index)
|
||||
{
|
||||
glPrimitiveRestartIndex(m_restart_index);
|
||||
checkForGlError("glPrimitiveRestartIndex");
|
||||
}
|
||||
|
||||
if (m_indexed_array.m_count && m_draw_array_count)
|
||||
{
|
||||
LOG_WARNING(RSX, "m_indexed_array.m_count && draw_array_count");
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < m_textures_count; ++i)
|
||||
{
|
||||
if (!m_textures[i].IsEnabled()) continue;
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + i);
|
||||
checkForGlError("glActiveTexture");
|
||||
m_gl_textures[i].Create();
|
||||
m_gl_textures[i].Bind();
|
||||
checkForGlError(fmt::Format("m_gl_textures[%d].Bind", i));
|
||||
m_program.SetTex(i);
|
||||
m_gl_textures[i].Init(m_textures[i]);
|
||||
checkForGlError(fmt::Format("m_gl_textures[%d].Init", i));
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < m_textures_count; ++i)
|
||||
{
|
||||
if (!m_vertex_textures[i].IsEnabled()) continue;
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + m_textures_count + i);
|
||||
checkForGlError("glActiveTexture");
|
||||
m_gl_vertex_textures[i].Create();
|
||||
m_gl_vertex_textures[i].Bind();
|
||||
checkForGlError(fmt::Format("m_gl_vertex_textures[%d].Bind", i));
|
||||
m_program.SetVTex(i);
|
||||
m_gl_vertex_textures[i].Init(m_vertex_textures[i]);
|
||||
checkForGlError(fmt::Format("m_gl_vertex_textures[%d].Init", i));
|
||||
}
|
||||
|
||||
m_vao.Bind();
|
||||
|
||||
if (m_indexed_array.m_count)
|
||||
{
|
||||
LoadVertexData(m_indexed_array.index_min, m_indexed_array.index_max - m_indexed_array.index_min + 1);
|
||||
}
|
||||
|
||||
if (m_indexed_array.m_count || m_draw_array_count)
|
||||
{
|
||||
EnableVertexData(m_indexed_array.m_count ? true : false);
|
||||
|
||||
InitVertexData();
|
||||
InitFragmentData();
|
||||
}
|
||||
|
||||
if (m_indexed_array.m_count)
|
||||
{
|
||||
switch (m_indexed_array.m_type)
|
||||
{
|
||||
case CELL_GCM_DRAW_INDEX_ARRAY_TYPE_32:
|
||||
glDrawElements(m_draw_mode - 1, m_indexed_array.m_count, GL_UNSIGNED_INT, nullptr);
|
||||
checkForGlError("glDrawElements #4");
|
||||
break;
|
||||
|
||||
case CELL_GCM_DRAW_INDEX_ARRAY_TYPE_16:
|
||||
glDrawElements(m_draw_mode - 1, m_indexed_array.m_count, GL_UNSIGNED_SHORT, nullptr);
|
||||
checkForGlError("glDrawElements #2");
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_ERROR(RSX, "Bad indexed array type (%d)", m_indexed_array.m_type);
|
||||
break;
|
||||
}
|
||||
|
||||
DisableVertexData();
|
||||
m_indexed_array.Reset();
|
||||
}
|
||||
|
||||
if (m_draw_array_count)
|
||||
{
|
||||
//LOG_WARNING(RSX,"glDrawArrays(%d,%d,%d)", m_draw_mode - 1, m_draw_array_first, m_draw_array_count);
|
||||
glDrawArrays(m_draw_mode - 1, 0, m_draw_array_count);
|
||||
checkForGlError("glDrawArrays");
|
||||
DisableVertexData();
|
||||
}
|
||||
|
||||
WriteBuffers();*/
|
||||
}
|
||||
|
||||
void D3D12GSRender::Flip()
|
||||
{
|
||||
}
|
88
rpcs3/Emu/RSX/D3D12/D3D12GSRender.h
Normal file
88
rpcs3/Emu/RSX/D3D12/D3D12GSRender.h
Normal file
@ -0,0 +1,88 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <d3d12.h>
|
||||
#include "rpcs3/Ini.h"
|
||||
#include "Utilities/rPlatform.h" // only for rImage
|
||||
#include "Utilities/File.h"
|
||||
#include "Utilities/Log.h"
|
||||
#include "Emu/Memory/Memory.h"
|
||||
#include "Emu/System.h"
|
||||
#include "Emu/RSX/GSRender.h"
|
||||
|
||||
#include "D3D12RenderTargetSets.h"
|
||||
|
||||
#pragma comment (lib, "d3d12.lib")
|
||||
#pragma comment (lib, "dxgi.lib")
|
||||
#pragma comment (lib, "d3dcompiler.lib")
|
||||
|
||||
|
||||
class D3D12GSRender //TODO: find out why this used to inherit from wxWindow
|
||||
: //public wxWindow
|
||||
/*,*/ public GSRender
|
||||
{
|
||||
private:
|
||||
// std::vector<u8> m_vdata;
|
||||
// std::vector<PostDrawObj> m_post_draw_objs;
|
||||
|
||||
// GLProgram m_program;
|
||||
int m_fp_buf_num;
|
||||
int m_vp_buf_num;
|
||||
// GLProgramBuffer m_prog_buffer;
|
||||
|
||||
// GLFragmentProgram m_fragment_prog;
|
||||
// GLVertexProgram m_vertex_prog;
|
||||
|
||||
// GLTexture m_gl_textures[m_textures_count];
|
||||
// GLTexture m_gl_vertex_textures[m_textures_count];
|
||||
|
||||
// GLvao m_vao;
|
||||
// GLvbo m_vbo;
|
||||
// GLrbo m_rbo;
|
||||
D3D12RenderTargetSets m_fbo;
|
||||
ID3D12Device* m_device;
|
||||
ID3D12CommandQueue *m_commandQueueCopy;
|
||||
ID3D12CommandQueue *m_commandQueueGraphic;
|
||||
|
||||
void* m_context;
|
||||
|
||||
public:
|
||||
// GSFrameBase* m_frame;
|
||||
u32 m_draw_frames;
|
||||
u32 m_skip_frames;
|
||||
|
||||
D3D12GSRender();
|
||||
virtual ~D3D12GSRender();
|
||||
|
||||
private:
|
||||
virtual void Close() override;
|
||||
/* void EnableVertexData(bool indexed_draw = false);
|
||||
void DisableVertexData();
|
||||
void InitVertexData();
|
||||
void InitFragmentData();
|
||||
|
||||
void Enable(bool enable, const u32 cap);
|
||||
|
||||
bool LoadProgram();
|
||||
void WriteBuffers();
|
||||
void WriteDepthBuffer();
|
||||
void WriteColorBuffers();
|
||||
void WriteColorBufferA();
|
||||
void WriteColorBufferB();
|
||||
void WriteColorBufferC();
|
||||
void WriteColorBufferD();
|
||||
|
||||
void DrawObjects();*/
|
||||
void InitDrawBuffers();
|
||||
|
||||
protected:
|
||||
virtual void OnInit() override;
|
||||
virtual void OnInitThread() override;
|
||||
virtual void OnExitThread() override;
|
||||
virtual void OnReset() override;
|
||||
virtual void ExecCMD(u32 cmd) override;
|
||||
virtual void ExecCMD() override;
|
||||
virtual void Flip() override;
|
||||
};
|
||||
|
||||
#endif
|
11
rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.h
Normal file
11
rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.h
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
class D3D12RenderTargetSets
|
||||
{
|
||||
public:
|
||||
bool IsCreated()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
@ -7,6 +7,9 @@
|
||||
#include "GSManager.h"
|
||||
#include "Null/NullGSRender.h"
|
||||
#include "GL/GLGSRender.h"
|
||||
#ifdef WIN32
|
||||
#include "D3D12/D3D12GSRender.h"
|
||||
#endif
|
||||
|
||||
void GSInfo::Init()
|
||||
{
|
||||
@ -34,6 +37,9 @@ void GSManager::Init()
|
||||
default:
|
||||
case 0: m_render = new NullGSRender(); break;
|
||||
case 1: m_render = new GLGSRender(); break;
|
||||
#ifdef WIN32
|
||||
case 2: m_render = new D3D12GSRender(); break;
|
||||
#endif
|
||||
}
|
||||
//m_render->Init(GetInfo().outresolution.width, GetInfo().outresolution.height);
|
||||
}
|
||||
|
@ -474,7 +474,9 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
cbox_gs_render->Append("Null");
|
||||
cbox_gs_render->Append("OpenGL");
|
||||
//cbox_gs_render->Append("Software");
|
||||
#ifdef WIN32
|
||||
cbox_gs_render->Append("D3D12");
|
||||
#endif
|
||||
|
||||
for(int i = 1; i < WXSIZEOF(ResolutionTable); ++i)
|
||||
{
|
||||
|
@ -41,6 +41,7 @@
|
||||
<ClCompile Include="Emu\RSX\Common\FragmentProgramDecompiler.cpp" />
|
||||
<ClCompile Include="Emu\RSX\Common\ShaderParam.cpp" />
|
||||
<ClCompile Include="Emu\RSX\Common\VertexProgramDecompiler.cpp" />
|
||||
<ClCompile Include="Emu\RSX\D3D12\D3D12GSRender.cpp" />
|
||||
<ClCompile Include="Emu\RSX\GL\GLCommonDecompiler.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\lv2\sys_dbg.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\lv2\sys_fs.cpp" />
|
||||
@ -498,6 +499,8 @@
|
||||
<ClInclude Include="Emu\RSX\Common\ProgramStateCache.h" />
|
||||
<ClInclude Include="Emu\RSX\Common\ShaderParam.h" />
|
||||
<ClInclude Include="Emu\RSX\Common\VertexProgramDecompiler.h" />
|
||||
<ClInclude Include="Emu\RSX\D3D12\D3D12GSRender.h" />
|
||||
<ClInclude Include="Emu\RSX\D3D12\D3D12RenderTargetSets.h" />
|
||||
<ClInclude Include="Emu\RSX\GCM.h" />
|
||||
<ClInclude Include="Emu\RSX\GL\GLBuffers.h" />
|
||||
<ClInclude Include="Emu\RSX\GL\GLCommonDecompiler.h" />
|
||||
@ -719,7 +722,7 @@
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions);DX12_SUPPORT</PreprocessorDefinitions>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<ExceptionHandling>Async</ExceptionHandling>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
@ -758,7 +761,7 @@
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PreprocessorDefinitions>_UNICODE;UNICODE;MSVC_CRT_MEMLEAK_DETECTION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_UNICODE;UNICODE;MSVC_CRT_MEMLEAK_DETECTION;%(PreprocessorDefinitions);DX12_SUPPORT</PreprocessorDefinitions>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<ExceptionHandling>Async</ExceptionHandling>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
@ -782,6 +785,7 @@
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<AdditionalIncludeDirectories>
|
||||
</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions);DX12_SUPPORT</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@ -799,7 +803,7 @@
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<ExceptionHandling>Async</ExceptionHandling>
|
||||
<PreprocessorDefinitions>LLVM_AVAILABLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>LLVM_AVAILABLE;%(PreprocessorDefinitions);DX12_SUPPORT</PreprocessorDefinitions>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<AdditionalIncludeDirectories>
|
||||
</AdditionalIncludeDirectories>
|
||||
@ -817,4 +821,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
@ -90,6 +90,9 @@
|
||||
<Filter Include="Emu\GPU\RSX\Common">
|
||||
<UniqueIdentifier>{2a8841dc-bce0-41bb-9fcb-5bf1f8dda213}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Emu\GPU\RSX\D3D12">
|
||||
<UniqueIdentifier>{25818cb6-10d5-4ae3-8c5e-9dd79c306e53}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Crypto\aes.cpp">
|
||||
@ -965,6 +968,9 @@
|
||||
<ClCompile Include="Emu\SysCalls\Modules\sys_spu_.cpp">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\RSX\D3D12\D3D12GSRender.cpp">
|
||||
<Filter>Emu\GPU\RSX\D3D12</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Crypto\aes.h">
|
||||
@ -1828,5 +1834,11 @@
|
||||
<ClInclude Include="Emu\SysCalls\Modules\sceNp2.h">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\RSX\D3D12\D3D12GSRender.h">
|
||||
<Filter>Emu\GPU\RSX\D3D12</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\RSX\D3D12\D3D12RenderTargetSets.h">
|
||||
<Filter>Emu\GPU\RSX\D3D12</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
x
Reference in New Issue
Block a user