mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
nv2a: Fix variable shadowing complaints
This commit is contained in:
@@ -104,11 +104,10 @@ static GLuint create_gl_shader(GLenum gl_shader_type,
|
||||
|
||||
static void update_shader_constant_locations(ShaderBinding *binding, const ShaderState *state)
|
||||
{
|
||||
int i, j;
|
||||
char tmp[64];
|
||||
|
||||
/* set texture samplers */
|
||||
for (i = 0; i < NV2A_MAX_TEXTURES; i++) {
|
||||
for (int i = 0; i < NV2A_MAX_TEXTURES; i++) {
|
||||
char samplerName[16];
|
||||
snprintf(samplerName, sizeof(samplerName), "texSamp%d", i);
|
||||
GLint texSampLoc = glGetUniformLocation(binding->gl_program, samplerName);
|
||||
@@ -129,14 +128,14 @@ static void update_shader_constant_locations(ShaderBinding *binding, const Shade
|
||||
}
|
||||
|
||||
/* lookup fragment shader uniforms */
|
||||
for (i = 0; i < 9; i++) {
|
||||
for (j = 0; j < 2; j++) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
snprintf(tmp, sizeof(tmp), "c%d_%d", j, i);
|
||||
binding->psh_constant_loc[i][j] = glGetUniformLocation(binding->gl_program, tmp);
|
||||
}
|
||||
}
|
||||
binding->alpha_ref_loc = glGetUniformLocation(binding->gl_program, "alphaRef");
|
||||
for (i = 1; i < NV2A_MAX_TEXTURES; i++) {
|
||||
for (int i = 1; i < NV2A_MAX_TEXTURES; i++) {
|
||||
snprintf(tmp, sizeof(tmp), "bumpMat%d", i);
|
||||
binding->bump_mat_loc[i] = glGetUniformLocation(binding->gl_program, tmp);
|
||||
snprintf(tmp, sizeof(tmp), "bumpScale%d", i);
|
||||
@@ -151,7 +150,7 @@ static void update_shader_constant_locations(ShaderBinding *binding, const Shade
|
||||
}
|
||||
|
||||
/* lookup vertex shader uniforms */
|
||||
for(i = 0; i < NV2A_VERTEXSHADER_CONSTANTS; i++) {
|
||||
for (int i = 0; i < NV2A_VERTEXSHADER_CONSTANTS; i++) {
|
||||
snprintf(tmp, sizeof(tmp), "c[%d]", i);
|
||||
binding->vsh_constant_loc[i] = glGetUniformLocation(binding->gl_program, tmp);
|
||||
}
|
||||
@@ -161,19 +160,19 @@ static void update_shader_constant_locations(ShaderBinding *binding, const Shade
|
||||
binding->fog_param_loc = glGetUniformLocation(binding->gl_program, "fogParam");
|
||||
|
||||
binding->inv_viewport_loc = glGetUniformLocation(binding->gl_program, "invViewport");
|
||||
for (i = 0; i < NV2A_LTCTXA_COUNT; i++) {
|
||||
for (int i = 0; i < NV2A_LTCTXA_COUNT; i++) {
|
||||
snprintf(tmp, sizeof(tmp), "ltctxa[%d]", i);
|
||||
binding->ltctxa_loc[i] = glGetUniformLocation(binding->gl_program, tmp);
|
||||
}
|
||||
for (i = 0; i < NV2A_LTCTXB_COUNT; i++) {
|
||||
for (int i = 0; i < NV2A_LTCTXB_COUNT; i++) {
|
||||
snprintf(tmp, sizeof(tmp), "ltctxb[%d]", i);
|
||||
binding->ltctxb_loc[i] = glGetUniformLocation(binding->gl_program, tmp);
|
||||
}
|
||||
for (i = 0; i < NV2A_LTC1_COUNT; i++) {
|
||||
for (int i = 0; i < NV2A_LTC1_COUNT; i++) {
|
||||
snprintf(tmp, sizeof(tmp), "ltc1[%d]", i);
|
||||
binding->ltc1_loc[i] = glGetUniformLocation(binding->gl_program, tmp);
|
||||
}
|
||||
for (i = 0; i < NV2A_MAX_LIGHTS; i++) {
|
||||
for (int i = 0; i < NV2A_MAX_LIGHTS; i++) {
|
||||
snprintf(tmp, sizeof(tmp), "lightInfiniteHalfVector%d", i);
|
||||
binding->light_infinite_half_vector_loc[i] =
|
||||
glGetUniformLocation(binding->gl_program, tmp);
|
||||
@@ -187,7 +186,7 @@ static void update_shader_constant_locations(ShaderBinding *binding, const Shade
|
||||
binding->light_local_attenuation_loc[i] =
|
||||
glGetUniformLocation(binding->gl_program, tmp);
|
||||
}
|
||||
for (i = 0; i < 8; i++) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
snprintf(tmp, sizeof(tmp), "clipRegion[%d]", i);
|
||||
binding->clip_region_loc[i] = glGetUniformLocation(binding->gl_program, tmp);
|
||||
}
|
||||
|
||||
@@ -666,8 +666,6 @@ static TextureBinding* generate_texture(const TextureShape s,
|
||||
s.width, s.height, s.depth);
|
||||
|
||||
if (gl_target == GL_TEXTURE_CUBE_MAP) {
|
||||
|
||||
ColorFormatInfo f = kelvin_color_format_gl_map[s.color_format];
|
||||
unsigned int block_size;
|
||||
if (f.gl_internal_format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) {
|
||||
block_size = 8;
|
||||
|
||||
@@ -250,9 +250,9 @@ static MString* get_var(struct PixelShader *ps, int reg, bool is_dest)
|
||||
break;
|
||||
case PS_REGISTER_C0:
|
||||
if (ps->flags & PS_COMBINERCOUNT_UNIQUE_C0 || ps->cur_stage == 8) {
|
||||
MString *reg = mstring_from_fmt("c0_%d", ps->cur_stage);
|
||||
add_const_ref(ps, mstring_get_str(reg));
|
||||
return reg;
|
||||
MString *reg_name = mstring_from_fmt("c0_%d", ps->cur_stage);
|
||||
add_const_ref(ps, mstring_get_str(reg_name));
|
||||
return reg_name;
|
||||
} else { // Same c0
|
||||
add_const_ref(ps, "c0_0");
|
||||
return mstring_from_str("c0_0");
|
||||
@@ -260,9 +260,9 @@ static MString* get_var(struct PixelShader *ps, int reg, bool is_dest)
|
||||
break;
|
||||
case PS_REGISTER_C1:
|
||||
if (ps->flags & PS_COMBINERCOUNT_UNIQUE_C1 || ps->cur_stage == 8) {
|
||||
MString *reg = mstring_from_fmt("c1_%d", ps->cur_stage);
|
||||
add_const_ref(ps, mstring_get_str(reg));
|
||||
return reg;
|
||||
MString *reg_name = mstring_from_fmt("c1_%d", ps->cur_stage);
|
||||
add_const_ref(ps, mstring_get_str(reg_name));
|
||||
return reg_name;
|
||||
} else { // Same c1
|
||||
add_const_ref(ps, "c1_0");
|
||||
return mstring_from_str("c1_0");
|
||||
|
||||
@@ -238,12 +238,11 @@ void pgraph_vk_update_descriptor_sets(PGRAPHState *pg)
|
||||
|
||||
static void update_shader_constant_locations(ShaderBinding *binding)
|
||||
{
|
||||
int i, j;
|
||||
char tmp[64];
|
||||
|
||||
/* lookup fragment shader uniforms */
|
||||
for (i = 0; i < 9; i++) {
|
||||
for (j = 0; j < 2; j++) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
snprintf(tmp, sizeof(tmp), "c%d_%d", j, i);
|
||||
binding->psh_constant_loc[i][j] =
|
||||
uniform_index(&binding->fragment->uniforms, tmp);
|
||||
@@ -253,7 +252,7 @@ static void update_shader_constant_locations(ShaderBinding *binding)
|
||||
uniform_index(&binding->fragment->uniforms, "alphaRef");
|
||||
binding->fog_color_loc =
|
||||
uniform_index(&binding->fragment->uniforms, "fogColor");
|
||||
for (i = 1; i < NV2A_MAX_TEXTURES; i++) {
|
||||
for (int i = 1; i < NV2A_MAX_TEXTURES; i++) {
|
||||
snprintf(tmp, sizeof(tmp), "bumpMat%d", i);
|
||||
binding->bump_mat_loc[i] =
|
||||
uniform_index(&binding->fragment->uniforms, tmp);
|
||||
@@ -286,7 +285,7 @@ static void update_shader_constant_locations(ShaderBinding *binding)
|
||||
binding->ltctxb_loc = uniform_index(&binding->vertex->uniforms, "ltctxb");
|
||||
binding->ltc1_loc = uniform_index(&binding->vertex->uniforms, "ltc1");
|
||||
|
||||
for (i = 0; i < NV2A_MAX_LIGHTS; i++) {
|
||||
for (int i = 0; i < NV2A_MAX_LIGHTS; i++) {
|
||||
snprintf(tmp, sizeof(tmp), "lightInfiniteHalfVector%d", i);
|
||||
binding->light_infinite_half_vector_loc[i] =
|
||||
uniform_index(&binding->vertex->uniforms, tmp);
|
||||
@@ -455,10 +454,9 @@ static void shader_update_constants(PGRAPHState *pg, ShaderBinding *binding,
|
||||
bool fixed_function)
|
||||
{
|
||||
ShaderState *state = &binding->state;
|
||||
int i, j;
|
||||
|
||||
/* update combiner constants */
|
||||
for (i = 0; i < 9; i++) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
uint32_t constant[2];
|
||||
if (i == 8) {
|
||||
/* final combiner */
|
||||
@@ -469,7 +467,7 @@ static void shader_update_constants(PGRAPHState *pg, ShaderBinding *binding,
|
||||
constant[1] = pgraph_reg_r(pg, NV_PGRAPH_COMBINEFACTOR1 + i * 4);
|
||||
}
|
||||
|
||||
for (j = 0; j < 2; j++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
GLint loc = binding->psh_constant_loc[i][j];
|
||||
if (loc != -1) {
|
||||
float value[4];
|
||||
@@ -488,7 +486,7 @@ static void shader_update_constants(PGRAPHState *pg, ShaderBinding *binding,
|
||||
|
||||
|
||||
/* For each texture stage */
|
||||
for (i = 0; i < NV2A_MAX_TEXTURES; i++) {
|
||||
for (int i = 0; i < NV2A_MAX_TEXTURES; i++) {
|
||||
int loc;
|
||||
|
||||
/* Bump luminance only during stages 1 - 3 */
|
||||
@@ -576,13 +574,13 @@ static void shader_update_constants(PGRAPHState *pg, ShaderBinding *binding,
|
||||
{ &pg->ltc1[0][0], binding->ltc1_loc, NV2A_LTC1_COUNT },
|
||||
};
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(lighting_arrays); i++) {
|
||||
for (int i = 0; i < ARRAY_SIZE(lighting_arrays); i++) {
|
||||
uniform1iv(
|
||||
&binding->vertex->uniforms, lighting_arrays[i].locs,
|
||||
lighting_arrays[i].len * 4, (void *)lighting_arrays[i].v);
|
||||
}
|
||||
|
||||
for (i = 0; i < NV2A_MAX_LIGHTS; i++) {
|
||||
for (int i = 0; i < NV2A_MAX_LIGHTS; i++) {
|
||||
int loc = binding->light_infinite_half_vector_loc[i];
|
||||
if (loc != -1) {
|
||||
uniform1fv(&binding->vertex->uniforms, loc, 3,
|
||||
@@ -657,7 +655,7 @@ static void shader_update_constants(PGRAPHState *pg, ShaderBinding *binding,
|
||||
|
||||
uint32_t clip_regions[8][4];
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
uint32_t x = pgraph_reg_r(pg, NV_PGRAPH_WINDOWCLIPX0 + i * 4);
|
||||
unsigned int x_min = GET_MASK(x, NV_PGRAPH_WINDOWCLIPX0_XMIN);
|
||||
unsigned int x_max = GET_MASK(x, NV_PGRAPH_WINDOWCLIPX0_XMAX) + 1;
|
||||
|
||||
@@ -284,19 +284,20 @@ static void download_surface_to_buffer(NV2AState *d, SurfaceBinding *surface,
|
||||
BUFFER_STAGING_DST;
|
||||
VkBuffer copy_buffer = r->storage_buffers[copy_buffer_idx].buffer;
|
||||
|
||||
VkBufferMemoryBarrier pre_copy_dst_barrier = {
|
||||
.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
|
||||
.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
|
||||
.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.buffer = copy_buffer,
|
||||
.size = VK_WHOLE_SIZE
|
||||
};
|
||||
vkCmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 1,
|
||||
&pre_copy_dst_barrier, 0, NULL);
|
||||
|
||||
{
|
||||
VkBufferMemoryBarrier pre_copy_dst_barrier = {
|
||||
.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
|
||||
.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
|
||||
.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.buffer = copy_buffer,
|
||||
.size = VK_WHOLE_SIZE
|
||||
};
|
||||
vkCmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 1,
|
||||
&pre_copy_dst_barrier, 0, NULL);
|
||||
}
|
||||
vkCmdCopyImageToBuffer(cmd, surface_image_loc,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, copy_buffer,
|
||||
num_copy_regions, copy_regions);
|
||||
@@ -1179,10 +1180,6 @@ void pgraph_vk_upload_surface_data(NV2AState *d, SurfaceBinding *surface,
|
||||
!use_compute_to_convert_depth_stencil_format;
|
||||
|
||||
if (upscale) {
|
||||
unsigned int scaled_width = surface->width,
|
||||
scaled_height = surface->height;
|
||||
pgraph_apply_scaling_factor(pg, &scaled_width, &scaled_height);
|
||||
|
||||
VkImageBlit blitRegion = {
|
||||
.srcSubresource.aspectMask = surface->host_fmt.aspect,
|
||||
.srcSubresource.mipLevel = 0,
|
||||
|
||||
Reference in New Issue
Block a user