mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-12 17:58:37 +12:00
Merged elisha464 branch
This commit is contained in:
parent
01f3763eb4
commit
a7368cc893
9 changed files with 504 additions and 289 deletions
|
@ -12,6 +12,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gcmBuffer gcmBuffers[8];
|
gcmBuffer gcmBuffers[8];
|
||||||
|
GLuint flipTex;
|
||||||
|
|
||||||
int last_width = 0, last_height = 0, last_depth_format = 0;
|
int last_width = 0, last_height = 0, last_depth_format = 0;
|
||||||
|
|
||||||
|
@ -85,12 +86,15 @@ GLGSRender::GLGSRender()
|
||||||
, m_context(nullptr)
|
, m_context(nullptr)
|
||||||
{
|
{
|
||||||
m_frame = new GLGSFrame();
|
m_frame = new GLGSFrame();
|
||||||
|
|
||||||
|
glGenTextures(1, &flipTex);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLGSRender::~GLGSRender()
|
GLGSRender::~GLGSRender()
|
||||||
{
|
{
|
||||||
m_frame->Close();
|
m_frame->Close();
|
||||||
delete m_context;
|
delete m_context;
|
||||||
|
glDeleteTextures(1, &flipTex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGSRender::Enable(bool enable, const u32 cap)
|
void GLGSRender::Enable(bool enable, const u32 cap)
|
||||||
|
@ -304,17 +308,39 @@ void GLGSRender::DisableVertexData()
|
||||||
|
|
||||||
void GLGSRender::InitVertexData()
|
void GLGSRender::InitVertexData()
|
||||||
{
|
{
|
||||||
|
GLfloat scaleOffsetMat[16] = {1.0f, 0.0f, 0.0f, 0.0f,
|
||||||
|
0.0f, 1.0f, 0.0f, 0.0f,
|
||||||
|
0.0f, 0.0f, 1.0f, 0.0f,
|
||||||
|
0.0f, 0.0f, 0.0f, 1.0f};
|
||||||
|
int l;
|
||||||
|
|
||||||
for(u32 i=0; i<m_transform_constants.GetCount(); ++i)
|
for(u32 i=0; i<m_transform_constants.GetCount(); ++i)
|
||||||
{
|
{
|
||||||
const RSXTransformConstant& c = m_transform_constants[i];
|
const RSXTransformConstant& c = m_transform_constants[i];
|
||||||
const wxString name = wxString::Format("vc%u", c.id);
|
const wxString name = wxString::Format("vc%u", c.id);
|
||||||
const int l = m_program.GetLocation(name);
|
l = m_program.GetLocation(name);
|
||||||
checkForGlError("glGetUniformLocation " + name);
|
checkForGlError("glGetUniformLocation " + name);
|
||||||
|
|
||||||
//ConLog.Write(name + " x: %.02f y: %.02f z: %.02f w: %.02f", c.x, c.y, c.z, c.w);
|
//ConLog.Write(name + " x: %.02f y: %.02f z: %.02f w: %.02f", c.x, c.y, c.z, c.w);
|
||||||
glUniform4f(l, c.x, c.y, c.z, c.w);
|
glUniform4f(l, c.x, c.y, c.z, c.w);
|
||||||
checkForGlError("glUniform4f " + name + wxString::Format(" %d [%f %f %f %f]", l, c.x, c.y, c.z, c.w));
|
checkForGlError("glUniform4f " + name + wxString::Format(" %d [%f %f %f %f]", l, c.x, c.y, c.z, c.w));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scale
|
||||||
|
scaleOffsetMat[0] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_SCALE + (0x4*0)] / (m_width / 2.0f);
|
||||||
|
scaleOffsetMat[5] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_SCALE + (0x4*1)] / (m_height / 2.0f);
|
||||||
|
scaleOffsetMat[10] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_SCALE + (0x4*2)];
|
||||||
|
|
||||||
|
// Offset
|
||||||
|
scaleOffsetMat[3] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_OFFSET + (0x4*0)] - (m_width / 2.0f);
|
||||||
|
scaleOffsetMat[7] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_OFFSET + (0x4*1)] - (m_height / 2.0f);
|
||||||
|
scaleOffsetMat[11] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_OFFSET + (0x4*2)] - 1/2.0f;
|
||||||
|
|
||||||
|
scaleOffsetMat[3] /= m_width / 2.0f;
|
||||||
|
scaleOffsetMat[7] /= m_height / 2.0f;
|
||||||
|
|
||||||
|
l = m_program.GetLocation("scaleOffsetMat");
|
||||||
|
glUniformMatrix4fv(l, 1, false, scaleOffsetMat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGSRender::InitFragmentData()
|
void GLGSRender::InitFragmentData()
|
||||||
|
@ -736,13 +762,13 @@ void GLGSRender::ExecCMD()
|
||||||
|
|
||||||
if(m_set_viewport_horizontal && m_set_viewport_vertical)
|
if(m_set_viewport_horizontal && m_set_viewport_vertical)
|
||||||
{
|
{
|
||||||
glViewport(m_viewport_x, RSXThread::m_height-m_viewport_y-m_viewport_h, m_viewport_w, m_viewport_h);
|
//glViewport(m_viewport_x, m_viewport_y, m_viewport_w, m_viewport_h);
|
||||||
checkForGlError("glViewport");
|
checkForGlError("glViewport");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_set_scissor_horizontal && m_set_scissor_vertical)
|
if(m_set_scissor_horizontal && m_set_scissor_vertical)
|
||||||
{
|
{
|
||||||
glScissor(m_scissor_x, RSXThread::m_height-m_scissor_y-m_scissor_h, m_scissor_w, m_scissor_h);
|
glScissor(m_scissor_x, m_scissor_y, m_scissor_w, m_scissor_h);
|
||||||
checkForGlError("glScissor");
|
checkForGlError("glScissor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1029,6 +1055,12 @@ void GLGSRender::ExecCMD()
|
||||||
|
|
||||||
void GLGSRender::Flip()
|
void GLGSRender::Flip()
|
||||||
{
|
{
|
||||||
|
if(m_set_scissor_horizontal && m_set_scissor_vertical)
|
||||||
|
{
|
||||||
|
glScissor(0, 0, RSXThread::m_width, RSXThread::m_height);
|
||||||
|
checkForGlError("glScissor");
|
||||||
|
}
|
||||||
|
|
||||||
if(m_read_buffer)
|
if(m_read_buffer)
|
||||||
{
|
{
|
||||||
gcmBuffer* buffers = (gcmBuffer*)Memory.GetMemFromAddr(m_gcm_buffers_addr);
|
gcmBuffer* buffers = (gcmBuffer*)Memory.GetMemFromAddr(m_gcm_buffers_addr);
|
||||||
|
@ -1054,12 +1086,47 @@ void GLGSRender::Flip()
|
||||||
}
|
}
|
||||||
else if(m_fbo.IsCreated())
|
else if(m_fbo.IsCreated())
|
||||||
{
|
{
|
||||||
|
Array<u8> pixels;
|
||||||
|
pixels.SetCount(m_width * m_height * 4);
|
||||||
|
|
||||||
m_fbo.Bind(GL_READ_FRAMEBUFFER);
|
m_fbo.Bind(GL_READ_FRAMEBUFFER);
|
||||||
|
glReadPixels(0, 0, m_width, m_height, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, pixels.GetPtr());
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, flipTex);
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, pixels.GetPtr());
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrtho(0, 1, 0, 1, 0, 1);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
GLfbo::Bind(GL_DRAW_FRAMEBUFFER, 0);
|
GLfbo::Bind(GL_DRAW_FRAMEBUFFER, 0);
|
||||||
|
|
||||||
|
m_program.UnUse();
|
||||||
|
m_program.Use();
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_ACCUM_BUFFER_BIT);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glTexCoord2i(0, 1);
|
||||||
|
glVertex2i(0, 0);
|
||||||
|
|
||||||
|
glTexCoord2i(1, 1);
|
||||||
|
glVertex2i(1, 0);
|
||||||
|
|
||||||
|
glTexCoord2i(1, 0);
|
||||||
|
glVertex2i(1, 1);
|
||||||
|
|
||||||
|
glTexCoord2i(0, 0);
|
||||||
|
glVertex2i(0, 1);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
/*GLfbo::Bind(GL_DRAW_FRAMEBUFFER, 0);
|
||||||
GLfbo::Blit(
|
GLfbo::Blit(
|
||||||
m_surface_clip_x, m_surface_clip_y, m_surface_clip_x + m_surface_clip_w, m_surface_clip_y + m_surface_clip_h,
|
m_surface_clip_x, m_surface_clip_y, m_surface_clip_x + m_surface_clip_w, m_surface_clip_y + m_surface_clip_h,
|
||||||
m_surface_clip_x, m_surface_clip_y, m_surface_clip_x + m_surface_clip_w, m_surface_clip_y + m_surface_clip_h,
|
m_surface_clip_x, m_surface_clip_y, m_surface_clip_x + m_surface_clip_w, m_surface_clip_y + m_surface_clip_h,
|
||||||
GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
|
GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);*/
|
||||||
m_fbo.Bind();
|
m_fbo.Bind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1072,4 +1139,39 @@ void GLGSRender::Flip()
|
||||||
|
|
||||||
if(m_fbo.IsCreated())
|
if(m_fbo.IsCreated())
|
||||||
m_fbo.Bind();
|
m_fbo.Bind();
|
||||||
|
|
||||||
|
if(m_set_scissor_horizontal && m_set_scissor_vertical)
|
||||||
|
{
|
||||||
|
glScissor(m_scissor_x, m_scissor_y, m_scissor_w, m_scissor_h);
|
||||||
|
checkForGlError("glScissor");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t LinearToSwizzleAddress(
|
||||||
|
uint32_t x, uint32_t y, uint32_t z,
|
||||||
|
uint32_t log2_width, uint32_t log2_height, uint32_t log2_depth)
|
||||||
|
{
|
||||||
|
uint32_t offset = 0;
|
||||||
|
uint32_t shift_count = 0;
|
||||||
|
while(log2_width | log2_height | log2_depth){
|
||||||
|
if(log2_width){
|
||||||
|
offset |= (x & 0x01) << shift_count;
|
||||||
|
x >>= 1;
|
||||||
|
++shift_count;
|
||||||
|
--log2_width;
|
||||||
|
}
|
||||||
|
if(log2_height){
|
||||||
|
offset |= (y & 0x01) << shift_count;
|
||||||
|
y >>= 1;
|
||||||
|
++shift_count;
|
||||||
|
--log2_height;
|
||||||
|
}
|
||||||
|
if(log2_depth){
|
||||||
|
offset |= (z & 0x01) << shift_count;
|
||||||
|
z >>= 1;
|
||||||
|
++shift_count;
|
||||||
|
--log2_depth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
|
|
||||||
extern GLenum g_last_gl_error;
|
extern GLenum g_last_gl_error;
|
||||||
void printGlError(GLenum err, const char* situation);
|
void printGlError(GLenum err, const char* situation);
|
||||||
|
uint32_t LinearToSwizzleAddress(
|
||||||
|
uint32_t x, uint32_t y, uint32_t z,
|
||||||
|
uint32_t log2_width, uint32_t log2_height, uint32_t log2_depth);
|
||||||
|
|
||||||
#if RSX_DEBUG
|
#if RSX_DEBUG
|
||||||
#define checkForGlError(sit) if((g_last_gl_error = glGetError()) != GL_NO_ERROR) printGlError(g_last_gl_error, sit)
|
#define checkForGlError(sit) if((g_last_gl_error = glGetError()) != GL_NO_ERROR) printGlError(g_last_gl_error, sit)
|
||||||
|
@ -51,9 +54,11 @@ public:
|
||||||
case 1: return GL_REPEAT;
|
case 1: return GL_REPEAT;
|
||||||
case 2: return GL_MIRRORED_REPEAT;
|
case 2: return GL_MIRRORED_REPEAT;
|
||||||
case 3: return GL_CLAMP_TO_EDGE;
|
case 3: return GL_CLAMP_TO_EDGE;
|
||||||
case 4: return GL_TEXTURE_BORDER;
|
case 4: return GL_CLAMP_TO_BORDER;
|
||||||
case 5: return GL_CLAMP_TO_EDGE;//GL_CLAMP;
|
case 5: return GL_CLAMP_TO_EDGE;
|
||||||
//case 6: return GL_MIRROR_CLAMP_TO_EDGE_EXT;
|
case 6: return GL_MIRROR_CLAMP_TO_EDGE_EXT;
|
||||||
|
case 7: return GL_MIRROR_CLAMP_TO_BORDER_EXT;
|
||||||
|
case 8: return GL_MIRROR_CLAMP_EXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConLog.Error("Texture wrap error: bad wrap (%d).", wrap);
|
ConLog.Error("Texture wrap error: bad wrap (%d).", wrap);
|
||||||
|
@ -63,9 +68,9 @@ public:
|
||||||
void Init(RSXTexture& tex)
|
void Init(RSXTexture& tex)
|
||||||
{
|
{
|
||||||
Bind();
|
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;
|
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",
|
//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",
|
||||||
|
@ -77,12 +82,13 @@ public:
|
||||||
bool is_swizzled = (tex.GetFormat() & 0x20) == 0;
|
bool is_swizzled = (tex.GetFormat() & 0x20) == 0;
|
||||||
|
|
||||||
glPixelStorei(GL_PACK_ALIGNMENT, tex.m_pitch);
|
glPixelStorei(GL_PACK_ALIGNMENT, tex.m_pitch);
|
||||||
char* pixels = (char*)Memory.GetMemFromAddr(tex.GetOffset());
|
char* pixels = (char*)Memory.GetMemFromAddr(GetAddress(tex.GetOffset(), tex.GetLocation()));
|
||||||
|
char* unswizzledPixels;
|
||||||
|
|
||||||
switch(format)
|
switch(format)
|
||||||
{
|
{
|
||||||
case 0x81:
|
case 0x81:
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.m_width, tex.m_height, 0, GL_BLUE, GL_UNSIGNED_BYTE, pixels);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.GetWidth(), tex.GetHeight(), 0, GL_BLUE, GL_UNSIGNED_BYTE, pixels);
|
||||||
checkForGlError("GLTexture::Init() -> glTexImage2D");
|
checkForGlError("GLTexture::Init() -> glTexImage2D");
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE);
|
||||||
|
@ -94,39 +100,60 @@ public:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x85:
|
case 0x85:
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.m_width, tex.m_height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, pixels);
|
if(is_swizzled)
|
||||||
|
{
|
||||||
|
uint32_t *src, *dst;
|
||||||
|
uint32_t log2width, log2height;
|
||||||
|
|
||||||
|
unswizzledPixels = (char*)malloc(tex.GetWidth() * tex.GetHeight() * 4);
|
||||||
|
src = (uint32_t*)pixels;
|
||||||
|
dst = (uint32_t*)unswizzledPixels;
|
||||||
|
|
||||||
|
log2width = log(tex.GetWidth())/log(2);
|
||||||
|
log2height = log(tex.GetHeight())/log(2);
|
||||||
|
|
||||||
|
for(int i=0; i<tex.GetHeight(); i++)
|
||||||
|
{
|
||||||
|
for(int j=0; j<tex.GetWidth(); j++)
|
||||||
|
{
|
||||||
|
dst[(i*tex.GetHeight()) + j] = src[LinearToSwizzleAddress(j, i, 0, log2width, log2height, 0)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.GetWidth(), tex.GetHeight(), 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, is_swizzled ? unswizzledPixels : pixels);
|
||||||
checkForGlError("GLTexture::Init() -> glTexImage2D");
|
checkForGlError("GLTexture::Init() -> glTexImage2D");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x86:
|
case 0x86:
|
||||||
{
|
{
|
||||||
u32 size = ((tex.m_width + 3) / 4) * ((tex.m_height + 3) / 4) * 8;
|
u32 size = ((tex.GetWidth() + 3) / 4) * ((tex.GetHeight() + 3) / 4) * 8;
|
||||||
|
|
||||||
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, tex.m_width, tex.m_height, 0, size, pixels);
|
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, tex.GetWidth(), tex.GetHeight(), 0, size, pixels);
|
||||||
checkForGlError("GLTexture::Init() -> glCompressedTexImage2D");
|
checkForGlError("GLTexture::Init() -> glCompressedTexImage2D");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x87:
|
case 0x87:
|
||||||
{
|
{
|
||||||
u32 size = ((tex.m_width + 3) / 4) * ((tex.m_height + 3) / 4) * 16;
|
u32 size = ((tex.GetWidth() + 3) / 4) * ((tex.GetHeight() + 3) / 4) * 16;
|
||||||
|
|
||||||
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, tex.m_width, tex.m_height, 0, size, pixels);
|
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, tex.GetWidth(), tex.GetHeight(), 0, size, pixels);
|
||||||
checkForGlError("GLTexture::Init() -> glCompressedTexImage2D");
|
checkForGlError("GLTexture::Init() -> glCompressedTexImage2D");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x88:
|
case 0x88:
|
||||||
{
|
{
|
||||||
u32 size = ((tex.m_width + 3) / 4) * ((tex.m_height + 3) / 4) * 16;
|
u32 size = ((tex.GetWidth() + 3) / 4) * ((tex.GetHeight() + 3) / 4) * 16;
|
||||||
|
|
||||||
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, tex.m_width, tex.m_height, 0, size, pixels);
|
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, tex.GetWidth(), tex.GetHeight(), 0, size, pixels);
|
||||||
checkForGlError("GLTexture::Init() -> glCompressedTexImage2D");
|
checkForGlError("GLTexture::Init() -> glCompressedTexImage2D");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x94:
|
case 0x94:
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.m_width, tex.m_height, 0, GL_RED, GL_SHORT, pixels);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.GetWidth(), tex.GetHeight(), 0, GL_RED, GL_SHORT, pixels);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_ONE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_ONE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_ONE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_ONE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_ONE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_ONE);
|
||||||
|
@ -135,30 +162,30 @@ public:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x9a:
|
case 0x9a:
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.m_width, tex.m_height, 0, GL_BGRA, GL_HALF_FLOAT, pixels);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.GetWidth(), tex.GetHeight(), 0, GL_BGRA, GL_HALF_FLOAT, pixels);
|
||||||
checkForGlError("GLTexture::Init() -> glTexImage2D");
|
checkForGlError("GLTexture::Init() -> glTexImage2D");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x9e:
|
case 0x9e:
|
||||||
{
|
{
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.m_width, tex.m_height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, pixels);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.GetWidth(), tex.GetHeight(), 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, pixels);
|
||||||
checkForGlError("GLTexture::Init() -> glTexImage2D");
|
checkForGlError("GLTexture::Init() -> glTexImage2D");
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ONE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ONE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: ConLog.Error("Init tex error: Bad tex format (0x%x | 0x%x | 0x%x)", format, tex.GetFormat() & 0x20, tex.GetFormat() & 0x40); break;
|
default: ConLog.Error("Init tex error: Bad tex format (0x%x | %s | 0x%x)", format, is_swizzled ? "swizzled" : "linear", tex.GetFormat() & 0x40); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, tex.m_mipmap - 1);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, tex.Getmipmap() - 1);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, tex.m_mipmap > 1);
|
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, tex.Getmipmap() > 1);
|
||||||
|
|
||||||
if(format != 0x81 && format != 0x94)
|
if(format != 0x81 && format != 0x94)
|
||||||
{
|
{
|
||||||
u8 remap_a = tex.m_remap & 0x3;
|
u8 remap_a = tex.GetRemap() & 0x3;
|
||||||
u8 remap_r = (tex.m_remap >> 2) & 0x3;
|
u8 remap_r = (tex.GetRemap() >> 2) & 0x3;
|
||||||
u8 remap_g = (tex.m_remap >> 4) & 0x3;
|
u8 remap_g = (tex.GetRemap() >> 4) & 0x3;
|
||||||
u8 remap_b = (tex.m_remap >> 6) & 0x3;
|
u8 remap_b = (tex.GetRemap() >> 6) & 0x3;
|
||||||
|
|
||||||
static const int gl_remap[] =
|
static const int gl_remap[] =
|
||||||
{
|
{
|
||||||
|
@ -174,6 +201,8 @@ public:
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, gl_remap[remap_b]);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, gl_remap[remap_b]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkForGlError("GLTexture::Init() -> remap");
|
||||||
|
|
||||||
static const int gl_tex_zfunc[] =
|
static const int gl_tex_zfunc[] =
|
||||||
{
|
{
|
||||||
GL_NEVER,
|
GL_NEVER,
|
||||||
|
@ -186,14 +215,18 @@ public:
|
||||||
GL_ALWAYS,
|
GL_ALWAYS,
|
||||||
};
|
};
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GetGlWrap(tex.m_wraps));
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GetGlWrap(tex.GetWrapS()));
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GetGlWrap(tex.m_wrapt));
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GetGlWrap(tex.GetWrapT()));
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GetGlWrap(tex.m_wrapr));
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GetGlWrap(tex.GetWrapR()));
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, gl_tex_zfunc[tex.m_zfunc]);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, gl_tex_zfunc[tex.GetZfunc()]);
|
||||||
|
|
||||||
glTexEnvi(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, tex.m_bias);
|
checkForGlError("GLTexture::Init() -> parameters1");
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, tex.m_minlod);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, tex.m_maxlod);
|
glTexEnvi(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, tex.GetBias());
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, (tex.GetMinLOD() >> 8));
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, (tex.GetMaxLOD() >> 8));
|
||||||
|
|
||||||
|
checkForGlError("GLTexture::Init() -> parameters2");
|
||||||
|
|
||||||
static const int gl_tex_filter[] =
|
static const int gl_tex_filter[] =
|
||||||
{
|
{
|
||||||
|
@ -207,20 +240,28 @@ public:
|
||||||
GL_NEAREST,
|
GL_NEAREST,
|
||||||
};
|
};
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_tex_filter[tex.m_min_filter]);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_tex_filter[tex.GetMinFilter()]);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_tex_filter[tex.m_mag_filter]);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_tex_filter[tex.GetMagFilter()]);
|
||||||
|
|
||||||
|
checkForGlError("GLTexture::Init() -> filters");
|
||||||
|
|
||||||
//Unbind();
|
//Unbind();
|
||||||
|
|
||||||
|
if(is_swizzled && format == 0x85)
|
||||||
|
{
|
||||||
|
free(unswizzledPixels);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Save(RSXTexture& tex, const wxString& name)
|
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.GetWidth() || !tex.GetHeight()) return;
|
||||||
|
|
||||||
u32* alldata = new u32[tex.m_width * tex.m_height];
|
u32* alldata = new u32[tex.GetWidth() * tex.GetHeight()];
|
||||||
|
|
||||||
Bind();
|
Bind();
|
||||||
|
|
||||||
switch(tex.m_format & ~(0x20 | 0x40))
|
switch(tex.GetFormat() & ~(0x20 | 0x40))
|
||||||
{
|
{
|
||||||
case 0x81:
|
case 0x81:
|
||||||
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, alldata);
|
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, alldata);
|
||||||
|
@ -237,15 +278,15 @@ public:
|
||||||
|
|
||||||
{
|
{
|
||||||
wxFile f(name + ".raw", wxFile::write);
|
wxFile f(name + ".raw", wxFile::write);
|
||||||
f.Write(alldata, tex.m_width * tex.m_height * 4);
|
f.Write(alldata, tex.GetWidth() * tex.GetHeight() * 4);
|
||||||
}
|
}
|
||||||
u8* data = new u8[tex.m_width * tex.m_height * 3];
|
u8* data = new u8[tex.GetWidth() * tex.GetHeight() * 3];
|
||||||
u8* alpha = new u8[tex.m_width * tex.m_height];
|
u8* alpha = new u8[tex.GetWidth() * tex.GetHeight()];
|
||||||
|
|
||||||
u8* src = (u8*)alldata;
|
u8* src = (u8*)alldata;
|
||||||
u8* dst_d = data;
|
u8* dst_d = data;
|
||||||
u8* dst_a = alpha;
|
u8* dst_a = alpha;
|
||||||
for(u32 i=0; i<tex.m_width*tex.m_height;i++)
|
for(u32 i=0; i<tex.GetWidth()*tex.GetHeight();i++)
|
||||||
{
|
{
|
||||||
*dst_d++ = *src++;
|
*dst_d++ = *src++;
|
||||||
*dst_d++ = *src++;
|
*dst_d++ = *src++;
|
||||||
|
@ -254,7 +295,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
wxImage out;
|
wxImage out;
|
||||||
out.Create(tex.m_width, tex.m_height, data, alpha);
|
out.Create(tex.GetWidth(), tex.GetHeight(), data, alpha);
|
||||||
out.SaveFile(name, wxBITMAP_TYPE_PNG);
|
out.SaveFile(name, wxBITMAP_TYPE_PNG);
|
||||||
|
|
||||||
free(alldata);
|
free(alldata);
|
||||||
|
|
|
@ -319,7 +319,7 @@ wxString GLVertexDecompilerThread::BuildCode()
|
||||||
|
|
||||||
wxString f = wxEmptyString;
|
wxString f = wxEmptyString;
|
||||||
|
|
||||||
f += wxString::Format("void %s()\n{\n\tgl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f);\n%s}\n", m_funcs[0].name.wx_str(), BuildFuncBody(m_funcs[0]).wx_str());
|
f += wxString::Format("void %s()\n{\n\tgl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f);\n%sgl_Position = gl_Position * scaleOffsetMat;\n}\n", m_funcs[0].name.wx_str(), BuildFuncBody(m_funcs[0]).wx_str());
|
||||||
|
|
||||||
for(uint i=1; i<m_funcs.GetCount(); ++i)
|
for(uint i=1; i<m_funcs.GetCount(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -329,6 +329,7 @@ wxString GLVertexDecompilerThread::BuildCode()
|
||||||
static const wxString& prot =
|
static const wxString& prot =
|
||||||
"#version 330\n"
|
"#version 330\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
"uniform mat4 scaleOffsetMat = mat4(1.0);\n"
|
||||||
"%s\n"
|
"%s\n"
|
||||||
"%s\n"
|
"%s\n"
|
||||||
"%s";
|
"%s";
|
||||||
|
|
202
rpcs3/Emu/GS/RSXTexture.cpp
Normal file
202
rpcs3/Emu/GS/RSXTexture.cpp
Normal file
|
@ -0,0 +1,202 @@
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "RSXThread.h"
|
||||||
|
|
||||||
|
RSXTexture::RSXTexture()
|
||||||
|
{
|
||||||
|
m_index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
RSXTexture::RSXTexture(u8 index)
|
||||||
|
{
|
||||||
|
m_index = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RSXTexture::Init()
|
||||||
|
{
|
||||||
|
// Offset
|
||||||
|
methodRegisters[NV4097_SET_TEXTURE_OFFSET + (m_index*32)] = 0;
|
||||||
|
|
||||||
|
// Format
|
||||||
|
methodRegisters[NV4097_SET_TEXTURE_FORMAT + (m_index*32)] = 0;
|
||||||
|
|
||||||
|
// Address
|
||||||
|
methodRegisters[NV4097_SET_TEXTURE_ADDRESS + (m_index*32)] =
|
||||||
|
((/*wraps*/1) | ((/*anisoBias*/0) << 4) | ((/*wrapt*/1) << 8) | ((/*unsignedRemap*/0) << 12) |
|
||||||
|
((/*wrapr*/2) << 16) | ((/*gamma*/0) << 20) |((/*signedRemap*/0) << 24) | ((/*zfunc*/0) << 28));
|
||||||
|
|
||||||
|
// Control0
|
||||||
|
methodRegisters[NV4097_SET_TEXTURE_CONTROL0 + (m_index*32)] =
|
||||||
|
(((/*alphakill*/0) << 2) | (/*maxaniso*/0) << 4) | ((/*maxlod*/0xc00) << 7) | ((/*minlod*/0) << 19) | ((/*enable*/0) << 31);
|
||||||
|
|
||||||
|
// Control1
|
||||||
|
methodRegisters[NV4097_SET_TEXTURE_CONTROL1 + (m_index*32)] = 0xE4;
|
||||||
|
|
||||||
|
// Filter
|
||||||
|
methodRegisters[NV4097_SET_TEXTURE_FILTER + (m_index*32)] =
|
||||||
|
((/*bias*/0) | ((/*conv*/1) << 13) | ((/*min*/5) << 16) | ((/*mag*/2) << 24)
|
||||||
|
| ((/*as*/0) << 28) | ((/*rs*/0) << 29) | ((/*gs*/0) << 30) | ((/*bs*/0) << 31) );
|
||||||
|
|
||||||
|
// Image Rect
|
||||||
|
methodRegisters[NV4097_SET_TEXTURE_IMAGE_RECT + (m_index*32)] = (/*height*/1) | ((/*width*/1) << 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 RSXTexture::GetOffset() const
|
||||||
|
{
|
||||||
|
return methodRegisters[NV4097_SET_TEXTURE_OFFSET + (m_index*32)];
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 RSXTexture::GetLocation() const
|
||||||
|
{
|
||||||
|
return (methodRegisters[NV4097_SET_TEXTURE_FORMAT + (m_index*32)] & 0x3) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RSXTexture::isCubemap() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_FORMAT + (m_index*32)] >> 2) & 0x1);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 RSXTexture::GetBorderType() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_FORMAT + (m_index*32)] >> 3) & 0x1);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 RSXTexture::GetDimension() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_FORMAT + (m_index*32)] >> 4) & 0xf);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 RSXTexture::GetFormat() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_FORMAT + (m_index*32)] >> 8) & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 RSXTexture::Getmipmap() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_FORMAT + (m_index*32)] >> 16) & 0xffff);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 RSXTexture::GetWrapS() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_ADDRESS + (m_index*32)]) & 0xf);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 RSXTexture::GetWrapT() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_ADDRESS + (m_index*32)] >> 8) & 0xf);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 RSXTexture::GetWrapR() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_ADDRESS + (m_index*32)] >> 16) & 0xf);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 RSXTexture::GetUnsignedRemap() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_ADDRESS + (m_index*32)] >> 12) & 0xf);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 RSXTexture::GetZfunc() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_ADDRESS + (m_index*32)] >> 28) & 0xf);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 RSXTexture::GetGamma() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_ADDRESS + (m_index*32)] >> 20) & 0xf);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 RSXTexture::GetAnisoBias() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_ADDRESS + (m_index*32)] >> 4) & 0xf);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 RSXTexture::GetSignedRemap() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_ADDRESS + (m_index*32)] >> 24) & 0xf);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RSXTexture::IsEnabled() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_CONTROL0 + (m_index*32)] >> 31) & 0x1);
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 RSXTexture::GetMinLOD() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_CONTROL0 + (m_index*32)] >> 19) & 0xfff);
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 RSXTexture::GetMaxLOD() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_CONTROL0 + (m_index*32)] >> 7) & 0xfff);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 RSXTexture::GetMaxAniso() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_CONTROL0 + (m_index*32)] >> 4) & 0x7);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RSXTexture::IsAlphaKillEnabled() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_CONTROL0 + (m_index*32)] >> 2) & 0x1);
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 RSXTexture::GetRemap() const
|
||||||
|
{
|
||||||
|
return (methodRegisters[NV4097_SET_TEXTURE_CONTROL1 + (m_index*32)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 RSXTexture::GetBias() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_FILTER + (m_index*32)]) & 0x1fff);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 RSXTexture::GetMinFilter() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_FILTER + (m_index*32)] >> 16) & 0x7);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 RSXTexture::GetMagFilter() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_FILTER + (m_index*32)] >> 24) & 0x7);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 RSXTexture::GetConvolutionFilter() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_FILTER + (m_index*32)] >> 13) & 0xf);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RSXTexture::isASigned() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_FILTER + (m_index*32)] >> 28) & 0x1);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RSXTexture::isRSigned() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_FILTER + (m_index*32)] >> 29) & 0x1);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RSXTexture::isGSigned() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_FILTER + (m_index*32)] >> 30) & 0x1);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RSXTexture::isBSigned() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_FILTER + (m_index*32)] >> 31) & 0x1);
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 RSXTexture::GetWidth() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_IMAGE_RECT + (m_index*32)] >> 16) & 0xffff);
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 RSXTexture::GetHeight() const
|
||||||
|
{
|
||||||
|
return ((methodRegisters[NV4097_SET_TEXTURE_IMAGE_RECT + (m_index*32)]) & 0xffff);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RSXTexture::SetControl3(u16 depth, u32 pitch)
|
||||||
|
{
|
||||||
|
m_depth = depth;
|
||||||
|
m_pitch = pitch;
|
||||||
|
}
|
|
@ -3,6 +3,21 @@
|
||||||
|
|
||||||
#define ARGS(x) (Memory.Read32(Memory.RSXIOMem.GetStartAddr() + re(m_ctrl->get) + (4*(x+1))))
|
#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()
|
RSXVertexData::RSXVertexData()
|
||||||
: frequency(0)
|
: frequency(0)
|
||||||
, stride(0)
|
, stride(0)
|
||||||
|
@ -185,47 +200,11 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3
|
||||||
|
|
||||||
case_16(NV4097_SET_TEXTURE_OFFSET, 0x20):
|
case_16(NV4097_SET_TEXTURE_OFFSET, 0x20):
|
||||||
{
|
{
|
||||||
RSXTexture& tex = m_textures[index];
|
|
||||||
const u32 offset = ARGS(0);
|
|
||||||
u32 a1 = ARGS(1);
|
|
||||||
u8 location = (a1 & 0x3) - 1;
|
|
||||||
const bool cubemap = (a1 >> 2) & 0x1;
|
|
||||||
const u8 dimension = (a1 >> 4) & 0xf;
|
|
||||||
const u8 format = (a1 >> 8) & 0xff;
|
|
||||||
const u16 mipmap = (a1 >> 16) & 0xffff;
|
|
||||||
CMD_LOG("index = %d, offset=0x%x, location=0x%x, cubemap=0x%x, dimension=0x%x, format=0x%x, mipmap=0x%x",
|
|
||||||
index, offset, location, cubemap, dimension, format, mipmap);
|
|
||||||
|
|
||||||
if(location == 2)
|
|
||||||
{
|
|
||||||
ConLog.Error("Bad texture location.");
|
|
||||||
location = 1;
|
|
||||||
}
|
|
||||||
u32 tex_addr = GetAddress(offset, location);
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
gcmBuffer* buffers = (gcmBuffer*)Memory.GetMemFromAddr(m_gcm_buffers_addr);
|
|
||||||
if(!tex.m_width) tex.m_width = re(buffers[m_gcm_current_buffer].width);
|
|
||||||
if(!tex.m_height) tex.m_height = re(buffers[m_gcm_current_buffer].height);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case_16(NV4097_SET_TEXTURE_CONTROL0, 0x20):
|
case_16(NV4097_SET_TEXTURE_CONTROL0, 0x20):
|
||||||
{
|
{
|
||||||
RSXTexture& tex = m_textures[index];
|
|
||||||
u32 a0 = ARGS(0);
|
|
||||||
bool enable = a0 >> 31 ? true : false;
|
|
||||||
u16 minlod = (a0 >> 19) & 0xfff;
|
|
||||||
u16 maxlod = (a0 >> 7) & 0xfff;
|
|
||||||
u8 maxaniso = (a0 >> 2) & 0x7;
|
|
||||||
tex.SetControl0(enable, minlod, maxlod, maxaniso);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -294,8 +273,6 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3
|
||||||
|
|
||||||
case_16(NV4097_SET_TEXTURE_CONTROL1, 0x20):
|
case_16(NV4097_SET_TEXTURE_CONTROL1, 0x20):
|
||||||
{
|
{
|
||||||
RSXTexture& tex = m_textures[index];
|
|
||||||
tex.SetControl1(ARGS(0));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -311,36 +288,11 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3
|
||||||
|
|
||||||
case_16(NV4097_SET_TEXTURE_FILTER, 0x20):
|
case_16(NV4097_SET_TEXTURE_FILTER, 0x20):
|
||||||
{
|
{
|
||||||
RSXTexture& tex = m_textures[index];
|
|
||||||
u32 a0 = ARGS(0);
|
|
||||||
u16 bias = a0 & 0x1fff;
|
|
||||||
u8 conv = (a0 >> 13) & 0xf;
|
|
||||||
u8 min = (a0 >> 16) & 0x7;
|
|
||||||
u8 mag = (a0 >> 24) & 0x7;
|
|
||||||
u8 a_signed = (a0 >> 28) & 0x1;
|
|
||||||
u8 r_signed = (a0 >> 29) & 0x1;
|
|
||||||
u8 g_signed = (a0 >> 30) & 0x1;
|
|
||||||
u8 b_signed = (a0 >> 31) & 0x1;
|
|
||||||
|
|
||||||
tex.SetFilter(bias, min, mag, conv, a_signed, r_signed, g_signed, b_signed);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case_16(NV4097_SET_TEXTURE_ADDRESS, 0x20):
|
case_16(NV4097_SET_TEXTURE_ADDRESS, 0x20):
|
||||||
{
|
{
|
||||||
RSXTexture& tex = m_textures[index];
|
|
||||||
|
|
||||||
u32 a0 = ARGS(0);
|
|
||||||
u8 wraps = a0 & 0xf;
|
|
||||||
u8 aniso_bias = (a0 >> 4) & 0xf;
|
|
||||||
u8 wrapt = (a0 >> 8) & 0xf;
|
|
||||||
u8 unsigned_remap = (a0 >> 12) & 0xf;
|
|
||||||
u8 wrapr = (a0 >> 16) & 0xf;
|
|
||||||
u8 gamma = (a0 >> 20) & 0xf;
|
|
||||||
u8 signed_remap = (a0 >> 24) & 0xf;
|
|
||||||
u8 zfunc = a0 >> 28;
|
|
||||||
|
|
||||||
tex.SetAddress(wraps, wrapt, wrapr, unsigned_remap, zfunc, gamma, aniso_bias, signed_remap);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -350,26 +302,6 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3
|
||||||
|
|
||||||
case_16(NV4097_SET_TEXTURE_IMAGE_RECT, 32):
|
case_16(NV4097_SET_TEXTURE_IMAGE_RECT, 32):
|
||||||
{
|
{
|
||||||
RSXTexture& tex = m_textures[index];
|
|
||||||
|
|
||||||
u16 height = ARGS(0) & 0xffff;
|
|
||||||
u16 width = ARGS(0) >> 16;
|
|
||||||
CMD_LOG("width=%d, height=%d", width, height);
|
|
||||||
|
|
||||||
if(!width || !height)
|
|
||||||
{
|
|
||||||
ConLog.Warning("Bad texture rect: %dx%d (%dx%d)", width, height, tex.m_width, tex.m_height);
|
|
||||||
for(int i=0; i<count; ++i)
|
|
||||||
{
|
|
||||||
ConLog.Warning("*** 0x%x", ARGS(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!width) width = tex.m_width;
|
|
||||||
if(!height) height = tex.m_height;
|
|
||||||
}
|
|
||||||
tex.SetRect(width, height);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1391,6 +1323,11 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3
|
||||||
m_fog_param1 = (float&)a1;
|
m_fog_param1 = (float&)a1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case NV4097_SET_VIEWPORT_SCALE:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
@ -1427,11 +1364,6 @@ void RSXThread::End()
|
||||||
//Emu.GetCallbackManager().m_exit_callback.Handle(0x0122, 0);
|
//Emu.GetCallbackManager().m_exit_callback.Handle(0x0122, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(uint i=0; i<m_textures_count; ++i)
|
|
||||||
{
|
|
||||||
m_textures[i].m_enabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_indexed_array.Reset();
|
m_indexed_array.Reset();
|
||||||
m_fragment_constants.Clear();
|
m_fragment_constants.Clear();
|
||||||
m_transform_constants.Clear();
|
m_transform_constants.Clear();
|
||||||
|
@ -1446,6 +1378,7 @@ void RSXThread::End()
|
||||||
|
|
||||||
void RSXThread::Task()
|
void RSXThread::Task()
|
||||||
{
|
{
|
||||||
|
u8 inc;
|
||||||
ConLog.Write("RSX thread entry");
|
ConLog.Write("RSX thread entry");
|
||||||
|
|
||||||
OnInitThread();
|
OnInitThread();
|
||||||
|
@ -1454,6 +1387,8 @@ void RSXThread::Task()
|
||||||
{
|
{
|
||||||
wxCriticalSectionLocker lock(m_cs_main);
|
wxCriticalSectionLocker lock(m_cs_main);
|
||||||
|
|
||||||
|
inc=1;
|
||||||
|
|
||||||
u32 put, get;
|
u32 put, get;
|
||||||
se_t<u32>::func(put, std::atomic_load((volatile std::atomic<u32>*)((u8*)m_ctrl + offsetof(CellGcmControl, put))));
|
se_t<u32>::func(put, std::atomic_load((volatile std::atomic<u32>*)((u8*)m_ctrl + offsetof(CellGcmControl, put))));
|
||||||
se_t<u32>::func(get, std::atomic_load((volatile std::atomic<u32>*)((u8*)m_ctrl + offsetof(CellGcmControl, get))));
|
se_t<u32>::func(get, std::atomic_load((volatile std::atomic<u32>*)((u8*)m_ctrl + offsetof(CellGcmControl, get))));
|
||||||
|
@ -1504,6 +1439,7 @@ void RSXThread::Task()
|
||||||
if(cmd & CELL_GCM_METHOD_FLAG_NON_INCREMENT)
|
if(cmd & CELL_GCM_METHOD_FLAG_NON_INCREMENT)
|
||||||
{
|
{
|
||||||
//ConLog.Warning("non increment cmd! 0x%x", cmd);
|
//ConLog.Warning("non increment cmd! 0x%x", cmd);
|
||||||
|
inc=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cmd == 0)
|
if(cmd == 0)
|
||||||
|
@ -1513,6 +1449,11 @@ void RSXThread::Task()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(int i=0; i<count; i++)
|
||||||
|
{
|
||||||
|
methodRegisters[(cmd & 0xffff) + (i*4*inc)] = ARGS(i);
|
||||||
|
}
|
||||||
|
|
||||||
mem32_ptr_t args(Memory.RSXIOMem.GetStartAddr() + get + 4);
|
mem32_ptr_t args(Memory.RSXIOMem.GetStartAddr() + get + 4);
|
||||||
DoCmd(cmd, cmd & 0x3ffff, args, count);
|
DoCmd(cmd, cmd & 0x3ffff, args, count);
|
||||||
|
|
||||||
|
|
|
@ -12,144 +12,67 @@ enum Method
|
||||||
CELL_GCM_METHOD_FLAG_RETURN = 0x00020000,
|
CELL_GCM_METHOD_FLAG_RETURN = 0x00020000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern u32 methodRegisters[0xffff];
|
||||||
|
u32 GetAddress(u32 offset, u8 location);
|
||||||
|
|
||||||
class RSXTexture
|
class RSXTexture
|
||||||
{
|
{
|
||||||
|
u8 m_index;
|
||||||
public:
|
public:
|
||||||
bool m_enabled;
|
|
||||||
|
|
||||||
u32 m_width, m_height;
|
|
||||||
u32 m_offset;
|
|
||||||
|
|
||||||
bool m_cubemap;
|
|
||||||
u8 m_dimension;
|
|
||||||
u32 m_format;
|
|
||||||
u16 m_mipmap;
|
|
||||||
|
|
||||||
u32 m_pitch;
|
u32 m_pitch;
|
||||||
u16 m_depth;
|
u16 m_depth;
|
||||||
|
|
||||||
u16 m_minlod;
|
|
||||||
u16 m_maxlod;
|
|
||||||
u8 m_maxaniso;
|
|
||||||
|
|
||||||
u8 m_wraps;
|
|
||||||
u8 m_wrapt;
|
|
||||||
u8 m_wrapr;
|
|
||||||
u8 m_unsigned_remap;
|
|
||||||
u8 m_zfunc;
|
|
||||||
u8 m_gamma;
|
|
||||||
u8 m_aniso_bias;
|
|
||||||
u8 m_signed_remap;
|
|
||||||
|
|
||||||
u16 m_bias;
|
|
||||||
u8 m_min_filter;
|
|
||||||
u8 m_mag_filter;
|
|
||||||
u8 m_conv;
|
|
||||||
u8 m_a_signed;
|
|
||||||
u8 m_r_signed;
|
|
||||||
u8 m_g_signed;
|
|
||||||
u8 m_b_signed;
|
|
||||||
|
|
||||||
u32 m_remap;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RSXTexture()
|
RSXTexture();
|
||||||
: m_width(0), m_height(0)
|
RSXTexture(u8 index);
|
||||||
, m_offset(0)
|
void Init();
|
||||||
, m_enabled(false)
|
|
||||||
|
|
||||||
, m_cubemap(false)
|
// Offset
|
||||||
, m_dimension(0)
|
u32 GetOffset() const;
|
||||||
, m_format(0)
|
|
||||||
, m_mipmap(0)
|
|
||||||
, m_minlod(0)
|
|
||||||
, m_maxlod(1000)
|
|
||||||
, m_maxaniso(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetRect(const u32 width, const u32 height)
|
// Format
|
||||||
{
|
u8 GetLocation() const;
|
||||||
m_width = width;
|
bool isCubemap() const;
|
||||||
m_height = height;
|
u8 GetBorderType() const;
|
||||||
}
|
u8 GetDimension() const;
|
||||||
|
u8 GetFormat() const;
|
||||||
|
u16 Getmipmap() const;
|
||||||
|
|
||||||
void SetFormat(const bool cubemap, const u8 dimension, const u32 format, const u16 mipmap)
|
// Address
|
||||||
{
|
u8 GetWrapS() const;
|
||||||
m_cubemap = cubemap;
|
u8 GetWrapT() const;
|
||||||
m_dimension = dimension;
|
u8 GetWrapR() const;
|
||||||
m_format = format;
|
u8 GetUnsignedRemap() const;
|
||||||
m_mipmap = mipmap;
|
u8 GetZfunc() const;
|
||||||
}
|
u8 GetGamma() const;
|
||||||
|
u8 GetAnisoBias() const;
|
||||||
|
u8 GetSignedRemap() const;
|
||||||
|
|
||||||
void SetAddress(u8 wraps, u8 wrapt, u8 wrapr, u8 unsigned_remap, u8 zfunc, u8 gamma, u8 aniso_bias, u8 signed_remap)
|
// Control0
|
||||||
{
|
bool IsEnabled() const;
|
||||||
m_wraps = wraps;
|
u16 GetMinLOD() const;
|
||||||
m_wrapt = wrapt;
|
u16 GetMaxLOD() const;
|
||||||
m_wrapr = wrapr;
|
u8 GetMaxAniso() const;
|
||||||
m_unsigned_remap = unsigned_remap;
|
bool IsAlphaKillEnabled() const;
|
||||||
m_zfunc = zfunc;
|
|
||||||
m_gamma = gamma;
|
|
||||||
m_aniso_bias = aniso_bias;
|
|
||||||
m_signed_remap = signed_remap;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetControl0(const bool enable, const u16 minlod, const u16 maxlod, const u8 maxaniso)
|
// Control1
|
||||||
{
|
u32 GetRemap() const;
|
||||||
m_enabled = enable;
|
|
||||||
m_minlod = minlod;
|
|
||||||
m_maxlod = maxlod;
|
|
||||||
m_maxaniso = maxaniso;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetControl1(u32 remap)
|
// Filter
|
||||||
{
|
u16 GetBias() const;
|
||||||
m_remap = remap;
|
u8 GetMinFilter() const;
|
||||||
}
|
u8 GetMagFilter() const;
|
||||||
|
u8 GetConvolutionFilter() const;
|
||||||
|
bool isASigned() const;
|
||||||
|
bool isRSigned() const;
|
||||||
|
bool isGSigned() const;
|
||||||
|
bool isBSigned() const;
|
||||||
|
|
||||||
void SetControl3(u16 depth, u32 pitch)
|
// Image Rect
|
||||||
{
|
u16 GetWidth() const;
|
||||||
m_depth = depth;
|
u16 GetHeight() const;
|
||||||
m_pitch = pitch;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetFilter(u16 bias, u8 min, u8 mag, u8 conv, u8 a_signed, u8 r_signed, u8 g_signed, u8 b_signed)
|
void SetControl3(u16 depth, u32 pitch);
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 GetFormat() const
|
|
||||||
{
|
|
||||||
return m_format;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetOffset(const u32 offset)
|
|
||||||
{
|
|
||||||
m_offset = offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxSize GetRect() const
|
|
||||||
{
|
|
||||||
return wxSize(m_width, m_height);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsEnabled() const
|
|
||||||
{
|
|
||||||
return m_enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 GetOffset() const
|
|
||||||
{
|
|
||||||
return m_offset;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RSXVertexData
|
struct RSXVertexData
|
||||||
|
@ -561,6 +484,12 @@ protected:
|
||||||
m_point_x = 0;
|
m_point_x = 0;
|
||||||
m_point_y = 0;
|
m_point_y = 0;
|
||||||
|
|
||||||
|
// Construct Textures
|
||||||
|
for(int i=0; i<16; i++)
|
||||||
|
{
|
||||||
|
m_textures[i] = RSXTexture(i);
|
||||||
|
}
|
||||||
|
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -619,6 +548,11 @@ protected:
|
||||||
|
|
||||||
m_clear_surface_mask = 0;
|
m_clear_surface_mask = 0;
|
||||||
m_begin_end = 0;
|
m_begin_end = 0;
|
||||||
|
|
||||||
|
for(uint i=0; i<m_textures_count; ++i)
|
||||||
|
{
|
||||||
|
m_textures[i].Init();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Begin(u32 draw_mode);
|
void Begin(u32 draw_mode);
|
||||||
|
@ -633,19 +567,6 @@ protected:
|
||||||
virtual void ExecCMD() = 0;
|
virtual void ExecCMD() = 0;
|
||||||
virtual void Flip() = 0;
|
virtual void Flip() = 0;
|
||||||
|
|
||||||
u32 GetAddress(u32 offset, u8 location)
|
|
||||||
{
|
|
||||||
switch(location)
|
|
||||||
{
|
|
||||||
case CELL_GCM_LOCATION_LOCAL: return m_local_mem_addr + 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoadVertexData(u32 first, u32 count)
|
void LoadVertexData(u32 first, u32 count)
|
||||||
{
|
{
|
||||||
for(u32 i=0; i<m_vertex_count; ++i)
|
for(u32 i=0; i<m_vertex_count; ++i)
|
||||||
|
|
|
@ -293,11 +293,11 @@ void RSXDebugger::OnClickBuffer(wxMouseEvent& event)
|
||||||
if (event.GetId() == p_buffer_colorD->GetId()) SHOW_BUFFER(3);
|
if (event.GetId() == p_buffer_colorD->GetId()) SHOW_BUFFER(3);
|
||||||
if (event.GetId() == p_buffer_tex->GetId())
|
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].GetWidth() && render.m_textures[m_cur_texture].GetHeight())
|
||||||
MemoryViewerPanel::ShowImage(this,
|
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()), 1,
|
||||||
render.m_textures[m_cur_texture].m_width,
|
render.m_textures[m_cur_texture].GetWidth(),
|
||||||
render.m_textures[m_cur_texture].m_height, false);
|
render.m_textures[m_cur_texture].GetHeight(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef SHOW_BUFFER
|
#undef SHOW_BUFFER
|
||||||
|
@ -417,15 +417,15 @@ void RSXDebugger::GetBuffers()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw Texture
|
// 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))
|
if(!Memory.IsGoodAddr(TexBuffer_addr))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
unsigned char* TexBuffer = (unsigned char*)Memory.VirtualToRealAddr(TexBuffer_addr);
|
unsigned char* TexBuffer = (unsigned char*)Memory.VirtualToRealAddr(TexBuffer_addr);
|
||||||
|
|
||||||
u32 width = render.m_textures[m_cur_texture].m_width;
|
u32 width = render.m_textures[m_cur_texture].GetWidth();
|
||||||
u32 height = render.m_textures[m_cur_texture].m_height;
|
u32 height = render.m_textures[m_cur_texture].GetHeight();
|
||||||
unsigned char* buffer = (unsigned char*)malloc(width * height * 3);
|
unsigned char* buffer = (unsigned char*)malloc(width * height * 3);
|
||||||
memcpy(buffer, TexBuffer, width * height * 3);
|
memcpy(buffer, TexBuffer, width * height * 3);
|
||||||
|
|
||||||
|
@ -483,22 +483,25 @@ void RSXDebugger::GetTexture()
|
||||||
m_list_texture->DeleteAllItems();
|
m_list_texture->DeleteAllItems();
|
||||||
|
|
||||||
for(uint i=0; i<RSXThread::m_textures_count; ++i)
|
for(uint i=0; i<RSXThread::m_textures_count; ++i)
|
||||||
|
{
|
||||||
|
if(render.m_textures[i].IsEnabled())
|
||||||
{
|
{
|
||||||
m_list_texture->InsertItem(i, wxString::Format("%d", i));
|
m_list_texture->InsertItem(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, 1, wxString::Format("0x%x", GetAddress(render.m_textures[i].GetOffset(), render.m_textures[i].GetLocation())));
|
||||||
m_list_texture->SetItem(i, 2, render.m_textures[i].m_cubemap ? "True" : "False");
|
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].m_dimension));
|
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, 4, render.m_textures[i].IsEnabled() ? "True" : "False");
|
||||||
m_list_texture->SetItem(i, 5, wxString::Format("0x%x", render.m_textures[i].m_format));
|
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].m_mipmap));
|
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, 7, wxString::Format("0x%x", render.m_textures[i].m_pitch));
|
||||||
m_list_texture->SetItem(i, 8, wxString::Format("%dx%d",
|
m_list_texture->SetItem(i, 8, wxString::Format("%dx%d",
|
||||||
render.m_textures[i].m_width,
|
render.m_textures[i].GetWidth(),
|
||||||
render.m_textures[i].m_height));
|
render.m_textures[i].GetHeight()));
|
||||||
|
|
||||||
m_list_texture->SetItemBackgroundColour(i, wxColour(m_cur_texture == i ? "Wheat" : "White"));
|
m_list_texture->SetItemBackgroundColour(i, wxColour(m_cur_texture == i ? "Wheat" : "White"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RSXDebugger::GetSettings()
|
void RSXDebugger::GetSettings()
|
||||||
{
|
{
|
||||||
|
|
|
@ -243,6 +243,7 @@
|
||||||
<ClCompile Include="Emu\GS\GL\OpenGL.cpp" />
|
<ClCompile Include="Emu\GS\GL\OpenGL.cpp" />
|
||||||
<ClCompile Include="Emu\GS\GSManager.cpp" />
|
<ClCompile Include="Emu\GS\GSManager.cpp" />
|
||||||
<ClCompile Include="Emu\GS\GSRender.cpp" />
|
<ClCompile Include="Emu\GS\GSRender.cpp" />
|
||||||
|
<ClCompile Include="Emu\GS\RSXTexture.cpp" />
|
||||||
<ClCompile Include="Emu\GS\RSXThread.cpp" />
|
<ClCompile Include="Emu\GS\RSXThread.cpp" />
|
||||||
<ClCompile Include="Emu\HDD\HDD.cpp" />
|
<ClCompile Include="Emu\HDD\HDD.cpp" />
|
||||||
<ClCompile Include="Emu\Io\Keyboard.cpp" />
|
<ClCompile Include="Emu\Io\Keyboard.cpp" />
|
||||||
|
|
|
@ -393,6 +393,9 @@
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Loader\TRP.cpp">
|
<ClCompile Include="Loader\TRP.cpp">
|
||||||
<Filter>Loader</Filter>
|
<Filter>Loader</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Emu\GS\RSXTexture.cpp">
|
||||||
|
<Filter>Emu\GS</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Emu\SysCalls\Modules\sceNpTrophy.cpp">
|
<ClCompile Include="Emu\SysCalls\Modules\sceNpTrophy.cpp">
|
||||||
<Filter>Emu\SysCalls\Modules</Filter>
|
<Filter>Emu\SysCalls\Modules</Filter>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue