Removed texture_param and associated functions

This commit is contained in:
korenkonder
2024-06-09 14:07:53 +03:00
parent 01d1aba103
commit fe7e19637f
5 changed files with 45 additions and 116 deletions
+10 -15
View File
@@ -1250,7 +1250,7 @@ static void water_particle_init();
static void water_particle_free();
static void sub_1403B6ED0(RenderTexture* a1, RenderTexture* a2, RenderTexture* a3, ripple_emit_params& params);
static void sub_1403B6F60(GLuint a1, GLuint a2, GLuint a3, ripple_emit_params& params);
static void sub_1403B6F60(texture* a1, texture* a2, texture* a3, ripple_emit_params& params);
particle_event_data::particle_event_data() : type(), count(), size(), force() {
@@ -3303,7 +3303,7 @@ void EffectRipple::sub_1403584A0(RenderTexture* rt) {
field_BB8.SetColorDepthTextures(ripple_tex->glid);
field_BB8.Bind();
image_filter_scale(ripple_tex->glid, rt->GetColorTex(), 1.0f);
image_filter_scale(&field_BB8, rt->color_texture);
gl_state_bind_framebuffer(0);
}
@@ -6564,19 +6564,16 @@ static void sub_1403B6ED0(RenderTexture* a1, RenderTexture* a2, RenderTexture* a
uniform_value[U_RIPPLE] = 1;
else
uniform_value[U_RIPPLE] = 0;
sub_1403B6F60(a1->GetColorTex(), a2->GetColorTex(), a3->GetColorTex(), params);
sub_1403B6F60(a1->color_texture, a2->color_texture, a3->color_texture, params);
gl_state_bind_framebuffer(0);
}
static void sub_1403B6F60(GLuint a1, GLuint a2, GLuint a3, ripple_emit_params& params) {
if (!a1 || !a2 || !a3)
static void sub_1403B6F60(texture* a1, texture* a2, texture* a3, ripple_emit_params& params) {
if (!a1 || !a1->glid || !a2 || !a2->glid || !a3 || !a3->glid)
return;
texture_param tex_params[2];
texture_params_get(0, 0, a1, &tex_params[0], a2, &tex_params[1]);
int32_t width = tex_params[1].width;
int32_t height = tex_params[1].height;
int32_t width = a2->width;
int32_t height = a2->height;
GLint v43[4];
glGetIntegerv(GL_VIEWPORT, v43);
@@ -6591,21 +6588,19 @@ static void sub_1403B6F60(GLuint a1, GLuint a2, GLuint a3, ripple_emit_params& p
ripple_scene_ubo.WriteMemory(ripple_scene);
ripple_batch_shader_data ripple_batch = {};
ripple_batch.g_params = { params.wake_attn, params.speed, params.field_8, params.field_C };
ripple_batch.g_params = { params.wake_attn, 0.0f, 0.0f, 0.0f };
ripple_batch_ubo.WriteMemory(ripple_batch);
gl_state_bind_vertex_array(rctx_ptr->common_vao);
shaders_ft.set(SHADER_FT_RIPPLE);
ripple_scene_ubo.Bind(0);
ripple_batch_ubo.Bind(1);
gl_state_active_bind_texture_2d(0, a2);
gl_state_active_bind_texture_2d(1, a3);
gl_state_active_bind_texture_2d(0, a2->glid);
gl_state_active_bind_texture_2d(1, a3->glid);
shaders_ft.draw_arrays(GL_TRIANGLE_STRIP, 0, 4);
gl_state_active_bind_texture_2d(1, 0);
gl_state_active_bind_texture_2d(0, 0);
gl_state_bind_vertex_array(0);
glViewport(v43[0], v43[1], v43[2], v43[3]);
texture_params_restore(&tex_params[0], &tex_params[1]);
}
+34 -44
View File
@@ -617,7 +617,7 @@ namespace rndr {
for (int32_t i = reflect_blur_num, j = 0; i > 0; i--, j++) {
blur_filter_apply(rctx, &refl_buf_tex, &refl_tex,
reflect_blur_filter, 1.0f, 1.0f, 0.0f);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, refl_tex.GetWidth(), refl_tex.GetHeight());
image_filter_scale(&refl_tex, refl_buf_tex.color_texture);
}
}
else {
@@ -1113,15 +1113,16 @@ namespace rndr {
}
}
void image_filter_scale(GLuint dst, GLuint src, const vec4 scale) {
if (!dst || !src)
void image_filter_scale(RenderTexture* dst, texture* src, const vec4& scale) {
if (!dst || !dst->color_texture->glid || !dst->color_texture || !src || !src->glid)
return;
render_context* rctx = rctx_ptr;
gl_state_begin_event("`anonymous-namespace'::Impl::apply_no_filter_sub");
texture_param tex_params[2];
texture_params_get(dst, &tex_params[0], src, &tex_params[1]);
glViewport(0, 0, dst->color_texture->width, dst->color_texture->height);
dst->Bind();
filter_scene_shader_data filter_scene = {};
filter_scene.g_transform = { 1.0f, 1.0f, 0.0f, 0.0f };
@@ -1129,7 +1130,7 @@ void image_filter_scale(GLuint dst, GLuint src, const vec4 scale) {
rctx->filter_scene_ubo.WriteMemory(filter_scene);
imgfilter_batch_shader_data imgfilter_batch = {};
imgfilter_batch.g_color_scale = 1.0f;
imgfilter_batch.g_color_scale = scale;
imgfilter_batch.g_color_offset = 0.0f;
imgfilter_batch.g_texture_lod = 0.0f;
rctx->imgfilter_batch_ubo.WriteMemory(imgfilter_batch);
@@ -1138,12 +1139,10 @@ void image_filter_scale(GLuint dst, GLuint src, const vec4 scale) {
shaders_ft.set(SHADER_FT_IMGFILT);
rctx->filter_scene_ubo.Bind(0);
rctx->imgfilter_batch_ubo.Bind(1);
gl_state_active_bind_texture_2d(0, src);
gl_state_active_bind_texture_2d(0, src->glid);
gl_state_bind_sampler(0, rctx->render_samplers[0]);
gl_state_bind_vertex_array(rctx->common_vao);
shaders_ft.draw_arrays(GL_TRIANGLE_STRIP, 0, 4);
texture_params_restore(&tex_params[0], &tex_params[1]);
gl_state_end_event();
}
@@ -1261,15 +1260,15 @@ static void draw_pass_shadow_end_make_shadowmap(Shadow* shad, int32_t index, int
RenderTexture& rend_buf_tex = rctx_ptr->shadow_buffer;
rend_tex->Bind();
image_filter_scale(rend_tex->GetColorTex(),
shad->curr_render_textures[0]->GetColorTex(), 1.0f);
image_filter_scale(rend_tex,
shad->curr_render_textures[0]->color_texture);
rend_buf_tex.Bind();
if (shad->blur_filter_enable[index]) {
for (int32_t i = shad->near_blur, j = 0; i > 0; i--, j++) {
blur_filter_apply(rctx, &rend_buf_tex, rend_tex,
shad->blur_filter, 1.0f, 1.0f, 0.0f);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, rend_buf_tex.GetWidth(), rend_buf_tex.GetHeight());
image_filter_scale(rend_tex, rend_buf_tex.color_texture);
}
}
else {
@@ -1285,19 +1284,13 @@ static void draw_pass_shadow_end_make_shadowmap(Shadow* shad, int32_t index, int
static void draw_pass_shadow_filter(RenderTexture* a1, RenderTexture* a2,
RenderTexture* a3, float_t sigma, float_t far_texel_offset, bool enable_lit_proj) {
GLuint v7 = a1->GetColorTex();
GLuint v9 = a2->GetColorTex();
GLuint v11 = v7;
texture* v7 = a1->color_texture;
texture* v9 = a2->color_texture;
texture* v11 = v7;
if (a3)
v11 = a3->GetDepthTex();
v11 = a3->depth_texture;
if (!v7 || !v9 || !v11)
return;
texture_param tex_params[2];
texture_params_get(v7, &tex_params[0], v9, &tex_params[1]);
if (tex_params[0].width != tex_params[1].width
|| tex_params[0].height != tex_params[1].height)
if (!v7 || !v9 || !v11 || v7->width != v9->width || v7->height != v9->height)
return;
render_context* rctx = rctx_ptr;
@@ -1309,7 +1302,7 @@ static void draw_pass_shadow_filter(RenderTexture* a1, RenderTexture* a2,
rctx->filter_scene_ubo.WriteMemory(filter_scene);
esm_filter_batch_shader_data esm_filter_batch = {};
esm_filter_batch.g_params = { 1.0f / (float_t)tex_params[0].width, 0.0f, far_texel_offset, far_texel_offset };
esm_filter_batch.g_params = { 1.0f / (float_t)v7->width, 0.0f, far_texel_offset, far_texel_offset };
double_t v6 = 1.0 / (sqrt(M_PI * 2.0) * sigma);
double_t v8 = -1.0 / (2.0 * sigma * sigma);
for (int32_t i = 0; i < 8; i++)
@@ -1320,11 +1313,13 @@ static void draw_pass_shadow_filter(RenderTexture* a1, RenderTexture* a2,
rctx->filter_scene_ubo.Bind(0);
rctx->esm_filter_batch_ubo.Bind(1);
glViewport(0, 0, v7->width, v7->height);
a2->Bind();
esm_filter_batch.g_params = { 1.0f / (float_t)tex_params[0].width, 0.0f, far_texel_offset, far_texel_offset };
esm_filter_batch.g_params = { 1.0f / (float_t)v7->width, 0.0f, far_texel_offset, far_texel_offset };
rctx->esm_filter_batch_ubo.WriteMemory(esm_filter_batch);
gl_state_active_bind_texture_2d(0, v11);
gl_state_active_bind_texture_2d(0, v11->glid);
if (a3) {
GLint swizzle[] = { GL_RED, GL_RED, GL_RED, GL_ONE };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
@@ -1339,25 +1334,23 @@ static void draw_pass_shadow_filter(RenderTexture* a1, RenderTexture* a2,
a1->Bind();
esm_filter_batch.g_params = { 0.0f, 1.0f / (float_t)tex_params[0].height, far_texel_offset, far_texel_offset };
esm_filter_batch.g_params = { 0.0f, 1.0f / (float_t)v7->height, far_texel_offset, far_texel_offset };
rctx->esm_filter_batch_ubo.WriteMemory(esm_filter_batch);
gl_state_active_bind_texture_2d(0, v9);
gl_state_active_bind_texture_2d(0, v9->glid);
gl_state_bind_sampler(0, rctx->render_samplers[0]);
gl_state_bind_vertex_array(rctx->common_vao);
shaders_ft.draw_arrays(GL_TRIANGLE_STRIP, 0, 4);
shader::unbind();
texture_params_restore(&tex_params[0], &tex_params[1]);
gl_state_end_event();
}
static void draw_pass_shadow_esm_filter(RenderTexture* dst, RenderTexture* buf, RenderTexture* src) {
GLuint dst_tex = dst->GetColorTex();
GLuint buf_tex = buf->GetColorTex();
GLuint src_tex = src->GetColorTex();
texture* dst_tex = dst->color_texture;
texture* buf_tex = buf->color_texture;
texture* src_tex = src->color_texture;
gl_state_begin_event("`anonymous-namespace'::Impl::apply_esm_min_filter");
if (!dst_tex || !buf_tex || !src_tex) {
if (!dst_tex || !dst_tex->glid || !buf_tex || !buf_tex->glid || !src_tex || !src_tex->glid) {
gl_state_end_event();
return;
}
@@ -1377,17 +1370,16 @@ static void draw_pass_shadow_esm_filter(RenderTexture* dst, RenderTexture* buf,
rctx->filter_scene_ubo.Bind(0);
rctx->esm_filter_batch_ubo.Bind(1);
texture_param tex_params[3];
texture_params_get(dst_tex, &tex_params[0], src_tex, &tex_params[1], buf_tex, &tex_params[2]);
glViewport(0, 0, dst_tex->width, dst_tex->height);
buf->Bind();
esm_filter_batch.g_params = { 1.0f / (float_t)tex_params[1].width,
1.0f / (float_t)tex_params[1].height, 0.0f, 0.0f };
esm_filter_batch.g_params = { 1.0f / (float_t)src_tex->width,
1.0f / (float_t)src_tex->height, 0.0f, 0.0f };
rctx->esm_filter_batch_ubo.WriteMemory(esm_filter_batch);
uniform_value[U_ESM_FILTER] = 0;
shaders_ft.set(SHADER_FT_ESMFILT);
gl_state_active_bind_texture_2d(0, src_tex);
gl_state_active_bind_texture_2d(0, src_tex->glid);
gl_state_bind_sampler(0, rctx->render_samplers[0]);
gl_state_bind_vertex_array(rctx->common_vao);
shaders_ft.draw_arrays(GL_TRIANGLE_STRIP, 0, 4);
@@ -1395,18 +1387,16 @@ static void draw_pass_shadow_esm_filter(RenderTexture* dst, RenderTexture* buf,
gl_state_begin_event("erosion");
dst->Bind();
esm_filter_batch.g_params = { 0.75f / (float_t)tex_params[2].width,
0.75f / (float_t)tex_params[2].height, 0.0f, 0.0f };
esm_filter_batch.g_params = { 0.75f / (float_t)buf_tex->width,
0.75f / (float_t)buf_tex->height, 0.0f, 0.0f };
rctx->esm_filter_batch_ubo.WriteMemory(esm_filter_batch);
uniform_value[U_ESM_FILTER] = 1;
shaders_ft.set(SHADER_FT_ESMFILT);
gl_state_active_bind_texture_2d(0, buf_tex);
gl_state_active_bind_texture_2d(0, buf_tex->glid);
gl_state_bind_sampler(0, rctx->render_samplers[0]);
gl_state_bind_vertex_array(rctx->common_vao);
shaders_ft.draw_arrays(GL_TRIANGLE_STRIP, 0, 4);
texture_params_restore(&tex_params[0], &tex_params[1], &tex_params[2]);
gl_state_end_event();
gl_state_end_event();
}
+1 -1
View File
@@ -133,7 +133,7 @@ namespace rndr {
};
}
extern void image_filter_scale(GLuint dst, GLuint src, const vec4 scale);
extern void image_filter_scale(RenderTexture* dst, texture* src, const vec4& scale = 1.0f);
extern void draw_pass_set_camera();
-46
View File
@@ -299,52 +299,6 @@ void texture_set_params(GLenum target, int32_t max_mipmap_level, bool use_high_a
glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, max_anisotropy);
}
void texture_params_get(GLuint tex_0, texture_param* tex_0_param,
GLuint tex_1, texture_param* tex_1_param, GLuint tex_2, texture_param* tex_2_param) {
gl_state_disable_depth_test();
if (tex_0_param) {
tex_0_param->width = 0;
tex_0_param->height = 0;
if (tex_0) {
gl_state_bind_texture_2d(tex_0);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &tex_0_param->width);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &tex_0_param->height);
}
}
if (tex_1_param) {
tex_1_param->width = 0;
tex_1_param->height = 0;
if (tex_1) {
gl_state_bind_texture_2d(tex_1);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &tex_1_param->width);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &tex_1_param->height);
}
}
if (tex_2_param) {
tex_2_param->width = 0;
tex_2_param->height = 0;
if (tex_2) {
gl_state_bind_texture_2d(tex_2);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &tex_2_param->width);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &tex_2_param->height);
}
}
gl_state_bind_texture_2d(0);
if (tex_0_param)
glViewport(0, 0, tex_0_param->width, tex_0_param->height);
}
void texture_params_restore(texture_param* tex_0_param,
texture_param* tex_1_param, texture_param* tex_2_param) {
for (int32_t i = 0; i < 4; i++) {
gl_state_active_bind_texture_2d(i, 0);
gl_state_bind_sampler(i, 0);
}
}
bool texture_txp_set_load(txp_set* t, texture*** texs, uint32_t* ids) {
if (!t || !texs || !ids)
return false;
-10
View File
@@ -94,11 +94,6 @@ struct texture_manager {
~texture_manager();
};
struct texture_param {
GLint width;
GLint height;
};
extern texture* texture_alloc(texture_id id);
extern void texture_apply_color_tone(texture* chg_tex,
texture* org_tex, const color_tone* col_tone);
@@ -116,11 +111,6 @@ extern void texture_array_free(texture** arr);
extern void texture_set_params(GLenum target, int32_t max_mipmap_level, bool use_high_anisotropy);
extern void texture_params_get(GLuint tex_0 = 0, texture_param* tex_0_param = 0,
GLuint tex_1 = 0, texture_param* tex_1_param = 0, GLuint tex_2 = 0, texture_param* tex_2_param = 0);
extern void texture_params_restore(texture_param* tex_0_param = 0,
texture_param* tex_1_param = 0, texture_param* tex_2_param = 0);
extern bool texture_txp_set_load(txp_set* t, texture*** texs, uint32_t* ids);
extern bool texture_txp_set_load(txp_set* t, texture*** texs, texture_id* ids);