diff --git a/rpcs3/Emu/GS/GL/GLGSRender.h b/rpcs3/Emu/GS/GL/GLGSRender.h index 9c74ac17b3..df3745444d 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.h +++ b/rpcs3/Emu/GS/GL/GLGSRender.h @@ -64,9 +64,9 @@ public: void Init(RSXTexture& tex) { Bind(); - if(!Memory.IsGoodAddr(tex.GetOffset())) + if(!Memory.IsGoodAddr(GetAddress(tex.GetOffset(), tex.GetLocation()))) { - ConLog.Error("Bad texture address=0x%x", tex.GetOffset()); + ConLog.Error("Bad texture address=0x%x", GetAddress(tex.GetOffset(), tex.GetLocation())); return; } //ConLog.Warning("texture addr = 0x%x, width = %d, height = %d, max_aniso=%d, mipmap=%d, remap=0x%x, zfunc=0x%x, wraps=0x%x, wrapt=0x%x, wrapr=0x%x, minlod=0x%x, maxlod=0x%x", @@ -78,7 +78,7 @@ public: bool is_swizzled = (tex.GetFormat() & 0x20) == 0; glPixelStorei(GL_PACK_ALIGNMENT, tex.m_pitch); - char* pixels = (char*)Memory.GetMemFromAddr(tex.GetOffset()); + char* pixels = (char*)Memory.GetMemFromAddr(GetAddress(tex.GetOffset(), tex.GetLocation())); switch(format) { @@ -151,8 +151,8 @@ public: default: ConLog.Error("Init tex error: Bad tex format (0x%x | 0x%x | 0x%x)", format, tex.GetFormat() & 0x20, tex.GetFormat() & 0x40); break; } - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, tex.m_mipmap - 1); - glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, tex.m_mipmap > 1); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, tex.Getmipmap() - 1); + glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, tex.Getmipmap() > 1); if(format != 0x81 && format != 0x94) { @@ -224,13 +224,13 @@ public: void Save(RSXTexture& tex, const wxString& name) { - if(!m_id || !tex.m_offset || !tex.m_width || !tex.m_height) return; + if(!m_id || !tex.GetOffset() || !tex.m_width || !tex.m_height) return; u32* alldata = new u32[tex.m_width * tex.m_height]; Bind(); - switch(tex.m_format & ~(0x20 | 0x40)) + switch(tex.GetFormat() & ~(0x20 | 0x40)) { case 0x81: glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, alldata); diff --git a/rpcs3/Emu/GS/RSXTexture.cpp b/rpcs3/Emu/GS/RSXTexture.cpp new file mode 100644 index 0000000000..1006b37afb --- /dev/null +++ b/rpcs3/Emu/GS/RSXTexture.cpp @@ -0,0 +1,136 @@ +#include "stdafx.h" +#include "RSXThread.h" + +RSXTexture::RSXTexture() + : m_width(0) + , m_height(0) + , m_enabled(false) + , m_minlod(0) + , m_maxlod(1000) + , m_maxaniso(0) + , m_wraps(1) + , m_wrapt(1) + , m_wrapr(3) + , m_zfunc(0) + , m_gamma(0) + , m_bias(0) + , m_remap(0xE4) + , m_min_filter(1) + , m_mag_filter(2) +{ + m_index = 0; +} + +RSXTexture::RSXTexture(u8 index) + : m_width(0) + , m_height(0) + , m_enabled(false) + , m_minlod(0) + , m_maxlod(1000) + , m_maxaniso(0) + , m_wraps(1) + , m_wrapt(1) + , m_wrapr(3) + , m_zfunc(0) + , m_gamma(0) + , m_bias(0) + , m_remap(0xE4) + , m_min_filter(1) + , m_mag_filter(2) +{ + m_index = index; +} + +u32 RSXTexture::GetOffset() const +{ + return methodRegisters[NV4097_SET_TEXTURE_OFFSET + (m_index*4)]; +} + +u8 RSXTexture::GetLocation() const +{ + return (methodRegisters[NV4097_SET_TEXTURE_FORMAT + (m_index*4)] & 0x3) - 1; +} + +bool RSXTexture::isCubemap() const +{ + return ((methodRegisters[NV4097_SET_TEXTURE_FORMAT + (m_index*4)] >> 2) & 0x1); +} + +u8 RSXTexture::GetBorderType() const +{ + return ((methodRegisters[NV4097_SET_TEXTURE_FORMAT + (m_index*4)] >> 3) & 0x1); +} + +u8 RSXTexture::GetDimension() const +{ + return ((methodRegisters[NV4097_SET_TEXTURE_FORMAT + (m_index*4)] >> 4) & 0xf); +} + +u8 RSXTexture::GetFormat() const +{ + return ((methodRegisters[NV4097_SET_TEXTURE_FORMAT + (m_index*4)] >> 8) & 0xff); +} + +u16 RSXTexture::Getmipmap() const +{ + return ((methodRegisters[NV4097_SET_TEXTURE_FORMAT + (m_index*4)] >> 16) & 0xffff); +} + +void RSXTexture::SetRect(const u32 width, const u32 height) +{ + m_width = width; + m_height = height; +} + +void RSXTexture::SetAddress(u8 wraps, u8 wrapt, u8 wrapr, u8 unsigned_remap, u8 zfunc, u8 gamma, u8 aniso_bias, u8 signed_remap) +{ + m_wraps = wraps; + m_wrapt = wrapt; + m_wrapr = wrapr; + m_unsigned_remap = unsigned_remap; + m_zfunc = zfunc; + m_gamma = gamma; + m_aniso_bias = aniso_bias; + m_signed_remap = signed_remap; +} + +void RSXTexture::SetControl0(const bool enable, const u16 minlod, const u16 maxlod, const u8 maxaniso) +{ + m_enabled = enable; + m_minlod = minlod; + m_maxlod = maxlod; + m_maxaniso = maxaniso; +} + +void RSXTexture::SetControl1(u32 remap) +{ + m_remap = remap; +} + +void RSXTexture::SetControl3(u16 depth, u32 pitch) +{ + m_depth = depth; + m_pitch = pitch; +} + +void RSXTexture::SetFilter(u16 bias, u8 min, u8 mag, u8 conv, u8 a_signed, u8 r_signed, u8 g_signed, u8 b_signed) +{ + m_bias = bias; + m_min_filter = min; + m_mag_filter = mag; + m_conv = conv; + m_a_signed = a_signed; + m_r_signed = r_signed; + m_g_signed = g_signed; + m_b_signed = b_signed; +} + +wxSize RSXTexture::GetRect() const +{ + return wxSize(m_width, m_height); +} + +bool RSXTexture::IsEnabled() const +{ + return m_enabled; +} \ No newline at end of file diff --git a/rpcs3/Emu/GS/RSXThread.cpp b/rpcs3/Emu/GS/RSXThread.cpp index 6e88524c11..0d82d494f6 100644 --- a/rpcs3/Emu/GS/RSXThread.cpp +++ b/rpcs3/Emu/GS/RSXThread.cpp @@ -3,6 +3,21 @@ #define ARGS(x) (Memory.Read32(Memory.RSXIOMem.GetStartAddr() + re(m_ctrl->get) + (4*(x+1)))) +u32 methodRegisters[0xffff]; + +u32 GetAddress(u32 offset, u8 location) +{ + switch(location) + { + case CELL_GCM_LOCATION_LOCAL: return Memory.RSXFBMem.GetStartAddr() + offset; + case CELL_GCM_LOCATION_MAIN: return Memory.RSXIOMem.getRealAddr(Memory.RSXIOMem.GetStartAddr() + offset); + } + + ConLog.Error("GetAddress(offset=0x%x, location=0x%x)", location); + assert(0); + return 0; +} + RSXVertexData::RSXVertexData() : frequency(0) , stride(0) @@ -205,8 +220,6 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3 if(!Memory.IsGoodAddr(tex_addr)) ConLog.Error("Bad texture[%d] addr = 0x%x #offset = 0x%x, location=%d", index, tex_addr, offset, location); //ConLog.Warning("texture addr = 0x%x #offset = 0x%x, location=%d", tex_addr, offset, location); - tex.SetOffset(tex_addr); - tex.SetFormat(cubemap, dimension, format, mipmap); if(!tex.m_width || !tex.m_height) { @@ -1441,6 +1454,7 @@ void RSXThread::End() void RSXThread::Task() { + u8 inc; ConLog.Write("RSX thread entry"); OnInitThread(); @@ -1449,6 +1463,8 @@ void RSXThread::Task() { wxCriticalSectionLocker lock(m_cs_main); + inc=1; + u32 put, get; se_t::func(put, std::atomic_load((volatile std::atomic*)((u8*)m_ctrl + offsetof(CellGcmControl, put)))); se_t::func(get, std::atomic_load((volatile std::atomic*)((u8*)m_ctrl + offsetof(CellGcmControl, get)))); @@ -1499,6 +1515,7 @@ void RSXThread::Task() if(cmd & CELL_GCM_METHOD_FLAG_NON_INCREMENT) { //ConLog.Warning("non increment cmd! 0x%x", cmd); + inc=0; } if(cmd == 0) @@ -1508,6 +1525,11 @@ void RSXThread::Task() continue; } + for(int i=0; iGetId()) SHOW_BUFFER(3); if (event.GetId() == p_buffer_tex->GetId()) { - if(Memory.IsGoodAddr(render.m_textures[m_cur_texture].m_offset) && render.m_textures[m_cur_texture].m_width && render.m_textures[m_cur_texture].m_height) + if(Memory.IsGoodAddr(GetAddress(render.m_textures[m_cur_texture].GetOffset(), render.m_textures[m_cur_texture].GetLocation())) && render.m_textures[m_cur_texture].m_width && render.m_textures[m_cur_texture].m_height) MemoryViewerPanel::ShowImage(this, - render.m_textures[m_cur_texture].m_offset, 0, + GetAddress(render.m_textures[m_cur_texture].GetOffset(), render.m_textures[m_cur_texture].GetLocation()), 0, render.m_textures[m_cur_texture].m_width, render.m_textures[m_cur_texture].m_height, false); } @@ -417,7 +417,7 @@ void RSXDebugger::GetBuffers() } // Draw Texture - u32 TexBuffer_addr = render.m_textures[m_cur_texture].m_offset; + u32 TexBuffer_addr = GetAddress(render.m_textures[m_cur_texture].GetOffset(), render.m_textures[m_cur_texture].GetLocation()); if(!Memory.IsGoodAddr(TexBuffer_addr)) return; @@ -485,12 +485,12 @@ void RSXDebugger::GetTexture() for(uint i=0; iInsertItem(i, wxString::Format("%d", i)); - m_list_texture->SetItem(i, 1, wxString::Format("0x%x", render.m_textures[i].m_offset)); - m_list_texture->SetItem(i, 2, render.m_textures[i].m_cubemap ? "True" : "False"); - m_list_texture->SetItem(i, 3, wxString::Format("%dD", render.m_textures[i].m_dimension)); + m_list_texture->SetItem(i, 1, wxString::Format("0x%x", GetAddress(render.m_textures[m_cur_texture].GetOffset(), render.m_textures[m_cur_texture].GetLocation()))); + m_list_texture->SetItem(i, 2, render.m_textures[i].isCubemap() ? "True" : "False"); + m_list_texture->SetItem(i, 3, wxString::Format("%dD", render.m_textures[i].GetDimension())); m_list_texture->SetItem(i, 4, render.m_textures[i].m_enabled ? "True" : "False"); - m_list_texture->SetItem(i, 5, wxString::Format("0x%x", render.m_textures[i].m_format)); - m_list_texture->SetItem(i, 6, wxString::Format("0x%x", render.m_textures[i].m_mipmap)); + m_list_texture->SetItem(i, 5, wxString::Format("0x%x", render.m_textures[i].GetFormat())); + m_list_texture->SetItem(i, 6, wxString::Format("0x%x", render.m_textures[i].Getmipmap())); m_list_texture->SetItem(i, 7, wxString::Format("0x%x", render.m_textures[i].m_pitch)); m_list_texture->SetItem(i, 8, wxString::Format("%dx%d", render.m_textures[i].m_width, diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index e8e50cafc2..96218bbf72 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -235,6 +235,7 @@ + diff --git a/rpcs3/rpcs3.vcxproj.filters b/rpcs3/rpcs3.vcxproj.filters index 45dd7d3051..4eabc97c06 100644 --- a/rpcs3/rpcs3.vcxproj.filters +++ b/rpcs3/rpcs3.vcxproj.filters @@ -373,6 +373,9 @@ Emu\SysCalls\lv2 + + Emu\GS +