mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-31 08:33:40 +00:00
Start documenting shader_parse.c
This commit is contained in:
parent
72f5e9a716
commit
33291c3486
@ -23,6 +23,14 @@
|
||||
#include <file/file_path.h>
|
||||
#include "../../general.h"
|
||||
|
||||
/**
|
||||
* wrap_mode_to_str:
|
||||
* @type : Wrap type.
|
||||
*
|
||||
* Translates wrap mode to human-readable string identifier.
|
||||
*
|
||||
* Returns: human-readable string identifier of wrap mode.
|
||||
**/
|
||||
static const char *wrap_mode_to_str(enum gfx_wrap_type type)
|
||||
{
|
||||
switch (type)
|
||||
@ -40,6 +48,14 @@ static const char *wrap_mode_to_str(enum gfx_wrap_type type)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* wrap_str_to_mode:
|
||||
* @type : Wrap type in human-readable string format.
|
||||
*
|
||||
* Translates wrap mode from human-readable string to enum mode value.
|
||||
*
|
||||
* Returns: enum mode value of wrap type.
|
||||
**/
|
||||
static enum gfx_wrap_type wrap_str_to_mode(const char *wrap_mode)
|
||||
{
|
||||
if (strcmp(wrap_mode, "clamp_to_border") == 0)
|
||||
@ -56,7 +72,16 @@ static enum gfx_wrap_type wrap_str_to_mode(const char *wrap_mode)
|
||||
return RARCH_WRAP_DEFAULT;
|
||||
}
|
||||
|
||||
/* CGP */
|
||||
/**
|
||||
* shader_parse_pass:
|
||||
* @conf : Preset file to read from.
|
||||
* @pass : Shader passes handle.
|
||||
* @i : Index of shader pass.
|
||||
*
|
||||
* Parses shader pass from preset file.
|
||||
*
|
||||
* Returns: true (1) if successful, otherwise false (0).
|
||||
**/
|
||||
static bool shader_parse_pass(config_file_t *conf, struct gfx_shader_pass *pass, unsigned i)
|
||||
{
|
||||
char shader_name[64], filter_name_buf[64], wrap_name_buf[64], wrap_mode[64];
|
||||
@ -218,6 +243,15 @@ static bool shader_parse_pass(config_file_t *conf, struct gfx_shader_pass *pass,
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* shader_parse_textures:
|
||||
* @conf : Preset file to read from.
|
||||
* @shader : Shader pass handle.
|
||||
*
|
||||
* Parses shader textures.
|
||||
*
|
||||
* Returns: true (1) if successful, otherwise false (0).
|
||||
**/
|
||||
static bool shader_parse_textures(config_file_t *conf,
|
||||
struct gfx_shader *shader)
|
||||
{
|
||||
@ -268,7 +302,17 @@ static bool shader_parse_textures(config_file_t *conf,
|
||||
return true;
|
||||
}
|
||||
|
||||
static struct gfx_shader_parameter *find_parameter(
|
||||
/**
|
||||
* shader_parse_find_parameter:
|
||||
* @params : Shader parameter handle.
|
||||
* @num_params : Number of shader params in @params.
|
||||
* @id : Identifier to search for.
|
||||
*
|
||||
* Finds a shader parameter with identifier @id in @params..
|
||||
*
|
||||
* Returns: handle to shader parameter if successful, otherwise NULL.
|
||||
**/
|
||||
static struct gfx_shader_parameter *shader_parse_find_parameter(
|
||||
struct gfx_shader_parameter *params, unsigned num_params, const char *id)
|
||||
{
|
||||
unsigned i;
|
||||
@ -278,9 +322,19 @@ static struct gfx_shader_parameter *find_parameter(
|
||||
if (!strcmp(params[i].id, id))
|
||||
return ¶ms[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gfx_shader_resolve_parameters:
|
||||
* @conf : Preset file to read from.
|
||||
* @shader : Shader passes handle.
|
||||
*
|
||||
* Resolves all shader parameters belonging to shaders.
|
||||
*
|
||||
* Returns: true (1) if successful, otherwise false (0).
|
||||
**/
|
||||
bool gfx_shader_resolve_parameters(config_file_t *conf,
|
||||
struct gfx_shader *shader)
|
||||
{
|
||||
@ -292,6 +346,7 @@ bool gfx_shader_resolve_parameters(config_file_t *conf,
|
||||
&shader->parameters[shader->num_parameters];
|
||||
|
||||
/* Find all parameters in our shaders. */
|
||||
|
||||
for (i = 0; i < shader->passes; i++)
|
||||
{
|
||||
char line[4096];
|
||||
@ -308,8 +363,9 @@ bool gfx_shader_resolve_parameters(config_file_t *conf,
|
||||
param->id, param->desc, ¶m->initial,
|
||||
¶m->minimum, ¶m->maximum, ¶m->step);
|
||||
|
||||
if (ret >= 5)
|
||||
{
|
||||
if (ret < 5)
|
||||
continue;
|
||||
|
||||
param->id[63] = '\0';
|
||||
param->desc[63] = '\0';
|
||||
|
||||
@ -324,7 +380,6 @@ bool gfx_shader_resolve_parameters(config_file_t *conf,
|
||||
shader->num_parameters++;
|
||||
param++;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
@ -344,7 +399,7 @@ bool gfx_shader_resolve_parameters(config_file_t *conf,
|
||||
id = strtok_r(NULL, ";", &save))
|
||||
{
|
||||
struct gfx_shader_parameter *parameter = (struct gfx_shader_parameter*)
|
||||
find_parameter(shader->parameters, shader->num_parameters, id);
|
||||
shader_parsefind_parameter(shader->parameters, shader->num_parameters, id);
|
||||
|
||||
if (!parameter)
|
||||
{
|
||||
|
@ -161,6 +161,15 @@ void gfx_shader_write_conf_cgp(config_file_t *conf,
|
||||
void gfx_shader_resolve_relative(struct gfx_shader *shader,
|
||||
const char *ref_path);
|
||||
|
||||
/**
|
||||
* gfx_shader_resolve_parameters:
|
||||
* @conf : Preset file to read from.
|
||||
* @shader : Shader passes handle.
|
||||
*
|
||||
* Resolves all shader parameters belonging to shaders.
|
||||
*
|
||||
* Returns: true (1) if successful, otherwise false (0).
|
||||
**/
|
||||
bool gfx_shader_resolve_parameters(config_file_t *conf,
|
||||
struct gfx_shader *shader);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user