From dbb9124bf6a18cdb732beb940bc89216148b7e0f Mon Sep 17 00:00:00 2001 From: jp9000 Date: Wed, 25 Jun 2014 20:29:46 -0700 Subject: [PATCH] Remove 'effect' param from effect param funcs Similar to the shader functions, the effect parameter functions take the effect as a parameter. However, the effect parameter is pretty pointless, because the effect parameter.. parameter stores the effect pointer interally. --- libobs/graphics/effect.c | 86 ++++++++-------------- libobs/graphics/graphics.h | 28 +++---- libobs/obs-source.c | 14 ++-- libobs/obs-video.c | 8 +- obs/window-basic-main.cpp | 2 +- obs/window-basic-preview.cpp | 2 +- plugins/linux-xcomposite/xcompcap-main.cpp | 2 +- plugins/linux-xshm/xcursor.c | 2 +- plugins/linux-xshm/xshm-input.c | 2 +- plugins/win-capture/dc-capture.c | 2 +- test/test-input/test-desktop.m | 3 +- 11 files changed, 59 insertions(+), 92 deletions(-) diff --git a/libobs/graphics/effect.c b/libobs/graphics/effect.c index e00f1761a..90e450022 100644 --- a/libobs/graphics/effect.c +++ b/libobs/graphics/effect.c @@ -226,29 +226,6 @@ eparam_t effect_getparambyname(effect_t effect, const char *name) return NULL; } -static inline bool matching_effect(effect_t effect, eparam_t param) -{ - if (effect != param->effect) { - blog(LOG_ERROR, "Effect and effect parameter do not match"); - return false; - } - - return true; -} - -void effect_getparaminfo(effect_t effect, eparam_t param, - struct effect_param_info *info) -{ - if (!effect || !param) - return; - - if (!matching_effect(effect, param)) - return; - - info->name = param->name; - info->type = param->type; -} - eparam_t effect_getviewprojmatrix(effect_t effect) { return effect ? effect->view_proj : NULL; @@ -259,16 +236,20 @@ eparam_t effect_getworldmatrix(effect_t effect) return effect ? effect->world : NULL; } -static inline void effect_setval_inline(effect_t effect, eparam_t param, +void effect_getparaminfo(eparam_t param, struct effect_param_info *info) +{ + if (!param) + return; + + info->name = param->name; + info->type = param->type; +} + +static inline void effect_setval_inline(eparam_t param, const void *data, size_t size) { bool size_changed; - if (!effect) { - blog(LOG_ERROR, "effect_setval_inline: invalid effect"); - return; - } - if (!param) { blog(LOG_ERROR, "effect_setval_inline: invalid param"); return; @@ -280,8 +261,6 @@ static inline void effect_setval_inline(effect_t effect, eparam_t param, } size_changed = param->cur_val.num != size; - if (!matching_effect(effect, param)) - return; if (size_changed) da_resize(param->cur_val, size); @@ -292,58 +271,53 @@ static inline void effect_setval_inline(effect_t effect, eparam_t param, } } -void effect_setbool(effect_t effect, eparam_t param, bool val) +void effect_setbool(eparam_t param, bool val) { - effect_setval_inline(effect, param, &val, sizeof(bool)); + effect_setval_inline(param, &val, sizeof(bool)); } -void effect_setfloat(effect_t effect, eparam_t param, float val) +void effect_setfloat(eparam_t param, float val) { - effect_setval_inline(effect, param, &val, sizeof(float)); + effect_setval_inline(param, &val, sizeof(float)); } -void effect_setint(effect_t effect, eparam_t param, int val) +void effect_setint(eparam_t param, int val) { - effect_setval_inline(effect, param, &val, sizeof(int)); + effect_setval_inline(param, &val, sizeof(int)); } -void effect_setmatrix4(effect_t effect, eparam_t param, - const struct matrix4 *val) +void effect_setmatrix4(eparam_t param, const struct matrix4 *val) { - effect_setval_inline(effect, param, val, sizeof(struct matrix4)); + effect_setval_inline(param, val, sizeof(struct matrix4)); } -void effect_setvec2(effect_t effect, eparam_t param, - const struct vec2 *val) +void effect_setvec2(eparam_t param, const struct vec2 *val) { - effect_setval_inline(effect, param, val, sizeof(struct vec2)); + effect_setval_inline(param, val, sizeof(struct vec2)); } -void effect_setvec3(effect_t effect, eparam_t param, - const struct vec3 *val) +void effect_setvec3(eparam_t param, const struct vec3 *val) { - effect_setval_inline(effect, param, val, sizeof(float) * 3); + effect_setval_inline(param, val, sizeof(float) * 3); } -void effect_setvec4(effect_t effect, eparam_t param, - const struct vec4 *val) +void effect_setvec4(eparam_t param, const struct vec4 *val) { - effect_setval_inline(effect, param, val, sizeof(struct vec4)); + effect_setval_inline(param, val, sizeof(struct vec4)); } -void effect_settexture(effect_t effect, eparam_t param, texture_t val) +void effect_settexture(eparam_t param, texture_t val) { - effect_setval_inline(effect, param, &val, sizeof(texture_t)); + effect_setval_inline(param, &val, sizeof(texture_t)); } -void effect_setval(effect_t effect, eparam_t param, const void *val, - size_t size) +void effect_setval(eparam_t param, const void *val, size_t size) { - effect_setval_inline(effect, param, val, size); + effect_setval_inline(param, val, size); } -void effect_setdefault(effect_t effect, eparam_t param) +void effect_setdefault(eparam_t param) { - effect_setval_inline(effect, param, param->default_val.array, + effect_setval_inline(param, param->default_val.array, param->default_val.num); } diff --git a/libobs/graphics/graphics.h b/libobs/graphics/graphics.h index d268544ab..2f33dbbd7 100644 --- a/libobs/graphics/graphics.h +++ b/libobs/graphics/graphics.h @@ -348,8 +348,6 @@ EXPORT void technique_endpass(technique_t technique); EXPORT size_t effect_numparams(effect_t effect); EXPORT eparam_t effect_getparambyidx(effect_t effect, size_t param); EXPORT eparam_t effect_getparambyname(effect_t effect, const char *name); -EXPORT void effect_getparaminfo(effect_t effect, eparam_t param, - struct effect_param_info *info); /** used internally */ EXPORT void effect_updateparams(effect_t effect); @@ -357,21 +355,17 @@ EXPORT void effect_updateparams(effect_t effect); EXPORT eparam_t effect_getviewprojmatrix(effect_t effect); EXPORT eparam_t effect_getworldmatrix(effect_t effect); -EXPORT void effect_setbool(effect_t effect, eparam_t param, bool val); -EXPORT void effect_setfloat(effect_t effect, eparam_t param, float val); -EXPORT void effect_setint(effect_t effect, eparam_t param, int val); -EXPORT void effect_setmatrix4(effect_t effect, eparam_t param, - const struct matrix4 *val); -EXPORT void effect_setvec2(effect_t effect, eparam_t param, - const struct vec2 *val); -EXPORT void effect_setvec3(effect_t effect, eparam_t param, - const struct vec3 *val); -EXPORT void effect_setvec4(effect_t effect, eparam_t param, - const struct vec4 *val); -EXPORT void effect_settexture(effect_t effect, eparam_t param, texture_t val); -EXPORT void effect_setval(effect_t effect, eparam_t param, const void *val, - size_t size); -EXPORT void effect_setdefault(effect_t effect, eparam_t param); +EXPORT void effect_getparaminfo(eparam_t param, struct effect_param_info *info); +EXPORT void effect_setbool(eparam_t param, bool val); +EXPORT void effect_setfloat(eparam_t param, float val); +EXPORT void effect_setint(eparam_t param, int val); +EXPORT void effect_setmatrix4(eparam_t param, const struct matrix4 *val); +EXPORT void effect_setvec2(eparam_t param, const struct vec2 *val); +EXPORT void effect_setvec3(eparam_t param, const struct vec3 *val); +EXPORT void effect_setvec4(eparam_t param, const struct vec4 *val); +EXPORT void effect_settexture(eparam_t param, texture_t val); +EXPORT void effect_setval(eparam_t param, const void *val, size_t size); +EXPORT void effect_setdefault(eparam_t param); /* --------------------------------------------------- * texture render helper functions diff --git a/libobs/obs-source.c b/libobs/obs-source.c index 8bc5083cd..0a4ec7c76 100644 --- a/libobs/obs-source.c +++ b/libobs/obs-source.c @@ -842,7 +842,7 @@ static const char *select_conversion_technique(enum video_format format) static inline void set_eparam(effect_t effect, const char *name, float val) { eparam_t param = effect_getparambyname(effect, name); - effect_setfloat(effect, param, val); + effect_setfloat(param, val); } static bool update_async_texrender(struct obs_source *source, @@ -871,7 +871,7 @@ static bool update_async_texrender(struct obs_source *source, technique_begin(tech); technique_beginpass(tech, 0); - effect_settexture(conv, effect_getparambyname(conv, "image"), tex); + effect_settexture(effect_getparambyname(conv, "image"), tex); set_eparam(conv, "width", (float)cx); set_eparam(conv, "height", (float)cy); set_eparam(conv, "width_i", 1.0f / cx); @@ -969,22 +969,22 @@ static inline void obs_source_draw_texture(struct obs_source *source, if (color_range_min) { size_t const size = sizeof(float) * 3; param = effect_getparambyname(effect, "color_range_min"); - effect_setval(effect, param, color_range_min, size); + effect_setval(param, color_range_min, size); } if (color_range_max) { size_t const size = sizeof(float) * 3; param = effect_getparambyname(effect, "color_range_max"); - effect_setval(effect, param, color_range_max, size); + effect_setval(param, color_range_max, size); } if (color_matrix) { param = effect_getparambyname(effect, "color_matrix"); - effect_setval(effect, param, color_matrix, sizeof(float) * 16); + effect_setval(param, color_matrix, sizeof(float) * 16); } param = effect_getparambyname(effect, "image"); - effect_settexture(effect, param, tex); + effect_settexture(param, tex); gs_draw_sprite(tex, source->async_flip ? GS_FLIP_V : 0, 0, 0); } @@ -1636,7 +1636,7 @@ static inline void render_filter_tex(texture_t tex, effect_t effect, eparam_t image = effect_getparambyname(effect, "image"); size_t passes, i; - effect_settexture(effect, image, tex); + effect_settexture(image, tex); passes = technique_begin(tech); for (i = 0; i < passes; i++) { diff --git a/libobs/obs-video.c b/libobs/obs-video.c index 405731330..cc8ea37e1 100644 --- a/libobs/obs-video.c +++ b/libobs/obs-video.c @@ -138,8 +138,8 @@ static inline void render_output_texture(struct obs_core_video *video, 0.000000f, 0.000000f, 0.000000f, 1.000000f }; - effect_setval(effect, matrix, mat_val, sizeof(mat_val)); - effect_settexture(effect, image, texture); + effect_setval(matrix, mat_val, sizeof(mat_val)); + effect_settexture(image, texture); passes = technique_begin(tech); for (i = 0; i < passes; i++) { @@ -155,7 +155,7 @@ static inline void render_output_texture(struct obs_core_video *video, static inline void set_eparam(effect_t effect, const char *name, float val) { eparam_t param = effect_getparambyname(effect, name); - effect_setfloat(effect, param, val); + effect_setfloat(param, val); } static void render_convert_texture(struct obs_core_video *video, @@ -187,7 +187,7 @@ static void render_convert_texture(struct obs_core_video *video, set_eparam(effect, "height_d2_i", 1.0f / (fheight * 0.5f)); set_eparam(effect, "input_height", (float)video->conversion_height); - effect_settexture(effect, image, texture); + effect_settexture(image, texture); gs_setrendertarget(target, NULL); set_render_size(video->output_width, video->conversion_height); diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp index 5b3e43863..643867da3 100644 --- a/obs/window-basic-main.cpp +++ b/obs/window-basic-main.cpp @@ -840,7 +840,7 @@ void OBSBasic::DrawBackdrop(float cx, float cy) vec4 colorVal; vec4_set(&colorVal, 0.0f, 0.0f, 0.0f, 1.0f); - effect_setvec4(solid, color, &colorVal); + effect_setvec4(color, &colorVal); technique_begin(tech); technique_beginpass(tech, 0); diff --git a/obs/window-basic-preview.cpp b/obs/window-basic-preview.cpp index 31d4e5df7..93ca6622e 100644 --- a/obs/window-basic-preview.cpp +++ b/obs/window-basic-preview.cpp @@ -718,7 +718,7 @@ void OBSBasicPreview::DrawSceneEditing() vec4 color; vec4_set(&color, 1.0f, 0.0f, 0.0f, 1.0f); - effect_setvec4(solid, effect_getparambyname(solid, "color"), &color); + effect_setvec4(effect_getparambyname(solid, "color"), &color); technique_begin(tech); technique_beginpass(tech, 0); diff --git a/plugins/linux-xcomposite/xcompcap-main.cpp b/plugins/linux-xcomposite/xcompcap-main.cpp index 5ca630a3a..3575c5176 100644 --- a/plugins/linux-xcomposite/xcompcap-main.cpp +++ b/plugins/linux-xcomposite/xcompcap-main.cpp @@ -438,7 +438,7 @@ void XCompcapMain::render(effect_t effect) return; eparam_t image = effect_getparambyname(effect, "image"); - effect_settexture(effect, image, p->tex); + effect_settexture(image, p->tex); gs_enable_blending(false); gs_draw_sprite(p->tex, 0, 0, 0); diff --git a/plugins/linux-xshm/xcursor.c b/plugins/linux-xshm/xcursor.c index 38b7ec411..e04137433 100644 --- a/plugins/linux-xshm/xcursor.c +++ b/plugins/linux-xshm/xcursor.c @@ -96,7 +96,7 @@ void xcursor_render(xcursor_t *data) { effect_t effect = gs_geteffect(); eparam_t image = effect_getparambyname(effect, "image"); - effect_settexture(effect, image, data->tex); + effect_settexture(image, data->tex); gs_matrix_push(); diff --git a/plugins/linux-xshm/xshm-input.c b/plugins/linux-xshm/xshm-input.c index 8d032995d..b3a3f8abf 100644 --- a/plugins/linux-xshm/xshm-input.c +++ b/plugins/linux-xshm/xshm-input.c @@ -268,7 +268,7 @@ static void xshm_video_render(void *vptr, effect_t effect) return; eparam_t image = effect_getparambyname(effect, "image"); - effect_settexture(effect, image, data->texture); + effect_settexture(image, data->texture); gs_enable_blending(false); gs_draw_sprite(data->texture, 0, 0, 0); diff --git a/plugins/win-capture/dc-capture.c b/plugins/win-capture/dc-capture.c index 8ff3fa1d9..abd6f1f05 100644 --- a/plugins/win-capture/dc-capture.c +++ b/plugins/win-capture/dc-capture.c @@ -182,7 +182,7 @@ static void draw_texture(struct dc_capture *capture, int id, effect_t effect) eparam_t image = effect_getparambyname(effect, "image"); size_t passes; - effect_settexture(effect, image, texture); + effect_settexture(image, texture); passes = technique_begin(tech); for (size_t i = 0; i < passes; i++) { diff --git a/test/test-input/test-desktop.m b/test/test-input/test-desktop.m index 77b88b086..7b79805d5 100644 --- a/test/test-input/test-desktop.m +++ b/test/test-input/test-desktop.m @@ -246,8 +246,7 @@ static void display_capture_video_render(void *data, effect_t effect) gs_load_samplerstate(dc->sampler, 0); technique_t tech = effect_gettechnique(dc->draw_effect, "Default"); - effect_settexture(dc->draw_effect, - effect_getparambyidx(dc->draw_effect, 1), + effect_settexture(effect_getparambyidx(dc->draw_effect, 1), dc->tex); technique_begin(tech); technique_beginpass(tech, 0);