gs-effect: Pass unmodified parameters as const reference
This commit is contained in:
parent
1d9a4ddbf5
commit
2faa68f9be
|
@ -54,7 +54,7 @@ static std::string load_file_as_code(std::filesystem::path file)
|
||||||
return std::string(buf.data(), buf.data() + size);
|
return std::string(buf.data(), buf.data() + size);
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect::effect(std::string code, std::string name)
|
gs::effect::effect(const std::string& code, const std::string& name)
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = gs::context();
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ gs::effect_technique gs::effect::get_technique(size_t idx)
|
||||||
return gs::effect_technique(get()->techniques.array + idx, this);
|
return gs::effect_technique(get()->techniques.array + idx, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_technique gs::effect::get_technique(std::string name)
|
gs::effect_technique gs::effect::get_technique(const std::string& name)
|
||||||
{
|
{
|
||||||
for (size_t idx = 0; idx < count_techniques(); idx++) {
|
for (size_t idx = 0; idx < count_techniques(); idx++) {
|
||||||
auto ptr = get()->techniques.array + idx;
|
auto ptr = get()->techniques.array + idx;
|
||||||
|
@ -103,7 +103,7 @@ gs::effect_technique gs::effect::get_technique(std::string name)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gs::effect::has_technique(std::string name)
|
bool gs::effect::has_technique(const std::string& name)
|
||||||
{
|
{
|
||||||
if (get_technique(name))
|
if (get_technique(name))
|
||||||
return true;
|
return true;
|
||||||
|
@ -124,7 +124,7 @@ gs::effect_parameter gs::effect::get_parameter(size_t idx)
|
||||||
return gs::effect_parameter(get()->params.array + idx, this);
|
return gs::effect_parameter(get()->params.array + idx, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_parameter gs::effect::get_parameter(std::string name)
|
gs::effect_parameter gs::effect::get_parameter(const std::string& name)
|
||||||
{
|
{
|
||||||
for (size_t idx = 0; idx < count_parameters(); idx++) {
|
for (size_t idx = 0; idx < count_parameters(); idx++) {
|
||||||
auto ptr = get()->params.array + idx;
|
auto ptr = get()->params.array + idx;
|
||||||
|
@ -136,14 +136,14 @@ gs::effect_parameter gs::effect::get_parameter(std::string name)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gs::effect::has_parameter(std::string name)
|
bool gs::effect::has_parameter(const std::string& name)
|
||||||
{
|
{
|
||||||
if (get_parameter(name))
|
if (get_parameter(name))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gs::effect::has_parameter(std::string name, effect_parameter::type type)
|
bool gs::effect::has_parameter(const std::string& name, effect_parameter::type type)
|
||||||
{
|
{
|
||||||
auto eprm = get_parameter(name);
|
auto eprm = get_parameter(name);
|
||||||
if (eprm)
|
if (eprm)
|
||||||
|
|
|
@ -42,20 +42,20 @@ namespace gs {
|
||||||
class effect : public std::shared_ptr<gs_effect_t> {
|
class effect : public std::shared_ptr<gs_effect_t> {
|
||||||
public:
|
public:
|
||||||
effect(){};
|
effect(){};
|
||||||
effect(std::string code, std::string name);
|
effect(const std::string& code, const std::string& name);
|
||||||
effect(std::filesystem::path file);
|
effect(std::filesystem::path file);
|
||||||
~effect();
|
~effect();
|
||||||
|
|
||||||
size_t count_techniques();
|
size_t count_techniques();
|
||||||
gs::effect_technique get_technique(size_t idx);
|
gs::effect_technique get_technique(size_t idx);
|
||||||
gs::effect_technique get_technique(std::string name);
|
gs::effect_technique get_technique(const std::string& name);
|
||||||
bool has_technique(std::string name);
|
bool has_technique(const std::string& name);
|
||||||
|
|
||||||
size_t count_parameters();
|
size_t count_parameters();
|
||||||
gs::effect_parameter get_parameter(size_t idx);
|
gs::effect_parameter get_parameter(size_t idx);
|
||||||
gs::effect_parameter get_parameter(std::string name);
|
gs::effect_parameter get_parameter(const std::string& name);
|
||||||
bool has_parameter(std::string name);
|
bool has_parameter(const std::string& name);
|
||||||
bool has_parameter(std::string name, effect_parameter::type type);
|
bool has_parameter(const std::string& name, effect_parameter::type type);
|
||||||
|
|
||||||
public /* Legacy Support */:
|
public /* Legacy Support */:
|
||||||
inline gs_effect_t* get_object()
|
inline gs_effect_t* get_object()
|
||||||
|
@ -63,11 +63,12 @@ namespace gs {
|
||||||
return get();
|
return get();
|
||||||
}
|
}
|
||||||
|
|
||||||
static gs::effect create(std::string file)
|
static gs::effect create(const std::string& file)
|
||||||
{
|
{
|
||||||
return gs::effect(file);
|
return gs::effect(file);
|
||||||
};
|
};
|
||||||
static gs::effect create(std::string code, std::string name)
|
|
||||||
|
static gs::effect create(const std::string& code, const std::string& name)
|
||||||
{
|
{
|
||||||
return gs::effect(code, name);
|
return gs::effect(code, name);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue