citra-emu
/
citra-canary
Archived
1
0
Fork 0

Renderer formatting edits

This commit is contained in:
tfarley 2015-06-06 23:24:11 -04:00
parent 66b0d799ee
commit 26bc816d7a
2 changed files with 29 additions and 26 deletions

View File

@ -793,10 +793,10 @@ void RasterizerOpenGL::ReloadColorBuffer() {
for (int x = 0; x < fb_color_texture.width; ++x) { for (int x = 0; x < fb_color_texture.width; ++x) {
const u32 coarse_y = y & ~7; const u32 coarse_y = y & ~7;
u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * fb_color_texture.width * bytes_per_pixel; u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * fb_color_texture.width * bytes_per_pixel;
u32 gl_px_idx = (x + y * fb_color_texture.width) * bytes_per_pixel; u32 gl_pixel_index = (x + y * fb_color_texture.width) * bytes_per_pixel;
u8* pixel = color_buffer + dst_offset; u8* pixel = color_buffer + dst_offset;
memcpy(&temp_fb_color_buffer[gl_px_idx], pixel, bytes_per_pixel); memcpy(&temp_fb_color_buffer[gl_pixel_index], pixel, bytes_per_pixel);
} }
} }
@ -834,11 +834,11 @@ void RasterizerOpenGL::ReloadDepthBuffer() {
for (int x = 0; x < fb_depth_texture.width; ++x) { for (int x = 0; x < fb_depth_texture.width; ++x) {
const u32 coarse_y = y & ~7; const u32 coarse_y = y & ~7;
u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * fb_depth_texture.width * bytes_per_pixel; u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * fb_depth_texture.width * bytes_per_pixel;
u32 gl_px_idx = (x + y * fb_depth_texture.width); u32 gl_pixel_index = (x + y * fb_depth_texture.width);
u8* pixel = depth_buffer + dst_offset; u8* pixel = depth_buffer + dst_offset;
u32 depth_stencil = *(u32*)pixel; u32 depth_stencil = *(u32*)pixel;
((u32*)temp_fb_depth_data)[gl_px_idx] = (depth_stencil << 8) | (depth_stencil >> 24); ((u32*)temp_fb_depth_data)[gl_pixel_index] = (depth_stencil << 8) | (depth_stencil >> 24);
} }
} }
} else { } else {
@ -846,10 +846,10 @@ void RasterizerOpenGL::ReloadDepthBuffer() {
for (int x = 0; x < fb_depth_texture.width; ++x) { for (int x = 0; x < fb_depth_texture.width; ++x) {
const u32 coarse_y = y & ~7; const u32 coarse_y = y & ~7;
u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * fb_depth_texture.width * bytes_per_pixel; u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * fb_depth_texture.width * bytes_per_pixel;
u32 gl_px_idx = (x + y * fb_depth_texture.width) * gl_bpp; u32 gl_pixel_index = (x + y * fb_depth_texture.width) * gl_bpp;
u8* pixel = depth_buffer + dst_offset; u8* pixel = depth_buffer + dst_offset;
memcpy(&temp_fb_depth_data[gl_px_idx], pixel, bytes_per_pixel); memcpy(&temp_fb_depth_data[gl_pixel_index], pixel, bytes_per_pixel);
} }
} }
} }
@ -890,10 +890,10 @@ void RasterizerOpenGL::CommitColorBuffer() {
for (int x = 0; x < fb_color_texture.width; ++x) { for (int x = 0; x < fb_color_texture.width; ++x) {
const u32 coarse_y = y & ~7; const u32 coarse_y = y & ~7;
u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * fb_color_texture.width * bytes_per_pixel; u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * fb_color_texture.width * bytes_per_pixel;
u32 gl_px_idx = x * bytes_per_pixel + y * fb_color_texture.width * bytes_per_pixel; u32 gl_pixel_index = x * bytes_per_pixel + y * fb_color_texture.width * bytes_per_pixel;
u8* pixel = color_buffer + dst_offset; u8* pixel = color_buffer + dst_offset;
memcpy(pixel, &temp_gl_color_buffer[gl_px_idx], bytes_per_pixel); memcpy(pixel, &temp_gl_color_buffer[gl_pixel_index], bytes_per_pixel);
} }
} }
} }
@ -930,10 +930,10 @@ void RasterizerOpenGL::CommitDepthBuffer() {
for (int x = 0; x < fb_depth_texture.width; ++x) { for (int x = 0; x < fb_depth_texture.width; ++x) {
const u32 coarse_y = y & ~7; const u32 coarse_y = y & ~7;
u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * fb_depth_texture.width * bytes_per_pixel; u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * fb_depth_texture.width * bytes_per_pixel;
u32 gl_px_idx = (x + y * fb_depth_texture.width); u32 gl_pixel_index = (x + y * fb_depth_texture.width);
u8* pixel = depth_buffer + dst_offset; u8* pixel = depth_buffer + dst_offset;
u32 depth_stencil = ((u32*)temp_gl_depth_data)[gl_px_idx]; u32 depth_stencil = ((u32*)temp_gl_depth_data)[gl_pixel_index];
*(u32*)pixel = (depth_stencil >> 8) | (depth_stencil << 24); *(u32*)pixel = (depth_stencil >> 8) | (depth_stencil << 24);
} }
} }
@ -942,10 +942,10 @@ void RasterizerOpenGL::CommitDepthBuffer() {
for (int x = 0; x < fb_depth_texture.width; ++x) { for (int x = 0; x < fb_depth_texture.width; ++x) {
const u32 coarse_y = y & ~7; const u32 coarse_y = y & ~7;
u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * fb_depth_texture.width * bytes_per_pixel; u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * fb_depth_texture.width * bytes_per_pixel;
u32 gl_px_idx = (x + y * fb_depth_texture.width) * gl_bpp; u32 gl_pixel_index = (x + y * fb_depth_texture.width) * gl_bpp;
u8* pixel = depth_buffer + dst_offset; u8* pixel = depth_buffer + dst_offset;
memcpy(pixel, &temp_gl_depth_data[gl_px_idx], bytes_per_pixel); memcpy(pixel, &temp_gl_depth_data[gl_pixel_index], bytes_per_pixel);
} }
} }
} }

View File

@ -84,10 +84,11 @@ void OpenGLState::Apply() {
// Color mask // Color mask
if (color_mask.red_enabled != cur_state.color_mask.red_enabled || if (color_mask.red_enabled != cur_state.color_mask.red_enabled ||
color_mask.green_enabled != cur_state.color_mask.green_enabled || color_mask.green_enabled != cur_state.color_mask.green_enabled ||
color_mask.blue_enabled != cur_state.color_mask.blue_enabled || color_mask.blue_enabled != cur_state.color_mask.blue_enabled ||
color_mask.alpha_enabled != cur_state.color_mask.alpha_enabled) { color_mask.alpha_enabled != cur_state.color_mask.alpha_enabled) {
glColorMask(color_mask.red_enabled, color_mask.green_enabled, color_mask.blue_enabled, color_mask.alpha_enabled); glColorMask(color_mask.red_enabled, color_mask.green_enabled,
color_mask.blue_enabled, color_mask.alpha_enabled);
} }
// Stencil test // Stencil test
@ -100,8 +101,8 @@ void OpenGLState::Apply() {
} }
if (stencil.test_func != cur_state.stencil.test_func || if (stencil.test_func != cur_state.stencil.test_func ||
stencil.test_ref != cur_state.stencil.test_ref || stencil.test_ref != cur_state.stencil.test_ref ||
stencil.test_mask != cur_state.stencil.test_mask) { stencil.test_mask != cur_state.stencil.test_mask) {
glStencilFunc(stencil.test_func, stencil.test_ref, stencil.test_mask); glStencilFunc(stencil.test_func, stencil.test_ref, stencil.test_mask);
} }
@ -125,17 +126,19 @@ void OpenGLState::Apply() {
} }
if (blend.color.red != cur_state.blend.color.red || if (blend.color.red != cur_state.blend.color.red ||
blend.color.green != cur_state.blend.color.green || blend.color.green != cur_state.blend.color.green ||
blend.color.blue != cur_state.blend.color.blue || blend.color.blue != cur_state.blend.color.blue ||
blend.color.alpha != cur_state.blend.color.alpha) { blend.color.alpha != cur_state.blend.color.alpha) {
glBlendColor(blend.color.red, blend.color.green, blend.color.blue, blend.color.alpha); glBlendColor(blend.color.red, blend.color.green,
blend.color.blue, blend.color.alpha);
} }
if (blend.src_rgb_func != cur_state.blend.src_rgb_func || if (blend.src_rgb_func != cur_state.blend.src_rgb_func ||
blend.dst_rgb_func != cur_state.blend.dst_rgb_func || blend.dst_rgb_func != cur_state.blend.dst_rgb_func ||
blend.src_a_func != cur_state.blend.src_a_func || blend.src_a_func != cur_state.blend.src_a_func ||
blend.dst_a_func != cur_state.blend.dst_a_func) { blend.dst_a_func != cur_state.blend.dst_a_func) {
glBlendFuncSeparate(blend.src_rgb_func, blend.dst_rgb_func, blend.src_a_func, blend.dst_a_func); glBlendFuncSeparate(blend.src_rgb_func, blend.dst_rgb_func,
blend.src_a_func, blend.dst_a_func);
} }
if (logic_op != cur_state.logic_op) { if (logic_op != cur_state.logic_op) {