This commit is contained in:
twinaphex 2016-09-11 15:07:07 +02:00
parent c97aa5e7ea
commit 606e37fcbd
8 changed files with 77 additions and 38 deletions

View File

@ -20,6 +20,10 @@
#include <string>
#include <vector>
#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
#include "../../include/Cg/cg.h"
#include "../../include/Cg/cgD3D9.h"
@ -27,15 +31,15 @@
#include <compat/strl.h>
#include <string/stdstring.h>
#include "../d3d.h"
#include "../d3d_shaders/opaque.cg.d3d9.h"
#include "render_chain_driver.h"
#include "../../video_driver.h"
#include "../../../configuration.h"
#include "../../../general.h"
#include "../../../performance_counters.h"
#include "../../../configuration.h"
#include "../../../runloop.h"
#include "../../../verbosity.h"
#include "../d3d.h"
#include "../d3d_shaders/opaque.cg.d3d9.h"
#define cg_d3d9_set_param_1f(param, x) if (param) cgD3D9SetUniform(param, x)
namespace {

View File

@ -14,11 +14,15 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
#include "../drivers/d3d.h"
#include "../font_driver.h"
#include "../../configuration.h"
#include "../../general.h"
#include "../../runloop.h"
#include "../include/d3d9/d3dx9core.h"

View File

@ -16,8 +16,12 @@
#include <xtl.h>
#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
#include "../font_driver.h"
#include "../../general.h"
#include "../../runloop.h"
typedef struct
{

View File

@ -18,9 +18,13 @@
#include <string/stdstring.h>
#include "../font_driver.h"
#ifdef HAVE_CONFIG_H
#include "../../runloop.h"
#endif
#include "../d3d/d3d.h"
#include "../../general.h"
#include "../font_driver.h"
#include "../../runloop.h"
#include "../drivers/d3d_shaders/font.hlsl.d3d9.h"

View File

@ -19,6 +19,11 @@
#include <string.h>
#include <CoreFoundation/CFString.h>
#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
#ifdef IOS
#include <CoreText/CoreText.h>
#include <CoreGraphics/CoreGraphics.h>
@ -27,7 +32,7 @@
#endif
#include "../font_driver.h"
#include "../../general.h"
#include "../../runloop.h"
#define CT_ATLAS_ROWS 16
#define CT_ATLAS_COLS 16

View File

@ -14,29 +14,32 @@
*/
#include <stdio.h>
#include <string.h>
#include <string>
#include <sstream>
#include <algorithm>
#include <file/file_path.h>
#include <streams/file_stream.h>
#include <lists/string_list.h>
#include <retro_miscellaneous.h>
#include "glslang_util.hpp"
#include "glslang.hpp"
#include "../../general.h"
#include "../../libretro-common/include/file/file_path.h"
#include "../../verbosity.h"
using namespace std;
static bool read_shader_file(const char *path, vector<string> *output, bool root_file)
{
char *buf = nullptr;
ssize_t len = 0;
const char *basename = path_basename(path);
char include_path[PATH_MAX];
char tmp[PATH_MAX];
vector<const char *> lines;
char *ptr = NULL;
char *buf = nullptr;
ssize_t len = 0;
char include_path[PATH_MAX_LENGTH] = {0};
char tmp[PATH_MAX_LENGTH] = {0};
const char *basename = path_basename(path);
if (!filestream_read_file(path, (void**)&buf, &len))
{
@ -44,8 +47,9 @@ static bool read_shader_file(const char *path, vector<string> *output, bool root
return false;
}
// Cannot use string_split since it removes blank lines (strtok).
char *ptr = buf;
/* Cannot use string_split since it removes blank lines (strtok). */
ptr = buf;
while (ptr && *ptr)
{
lines.push_back(ptr);
@ -75,13 +79,14 @@ static bool read_shader_file(const char *path, vector<string> *output, bool root
}
output->push_back(lines[0]);
// Allows us to use #line to make dealing with shader errors easier.
// This is supported by glslang, but since we always use glslang statically,
// this is fine.
/* Allows us to use #line to make dealing with shader errors easier.
* This is supported by glslang, but since we always use glslang statically,
* this is fine. */
output->push_back("#extension GL_GOOGLE_cpp_style_line_directive : require");
}
// At least VIM treats the first line as line #1, so offset everything by one.
/* At least VIM treats the first line as line #1,
* so offset everything by one. */
snprintf(tmp, sizeof(tmp), "#line %u \"%s\"", root_file ? 2 : 1, basename);
output->push_back(tmp);
@ -90,7 +95,9 @@ static bool read_shader_file(const char *path, vector<string> *output, bool root
const char *line = lines[i];
if (strstr(line, "#include ") == line)
{
char *c = (char*)strchr(line, '"');
char *closing = NULL;
char *c = (char*)strchr(line, '"');
if (!c)
{
RARCH_ERR("Invalid include statement \"%s\".\n", line);
@ -98,14 +105,18 @@ static bool read_shader_file(const char *path, vector<string> *output, bool root
return false;
}
c++;
char *closing = (char*)strchr(c, '"');
closing = (char*)strchr(c, '"');
if (!closing)
{
RARCH_ERR("Invalid include statement \"%s\".\n", line);
free(buf);
return false;
}
*closing = '\0';
fill_pathname_resolve_relative(include_path, path, c, sizeof(include_path));
if (!read_shader_file(include_path, output, false))
@ -114,15 +125,18 @@ static bool read_shader_file(const char *path, vector<string> *output, bool root
return false;
}
// After including a file, use line directive to pull it back to current file.
/* After including a file, use line directive
* to pull it back to current file. */
snprintf(tmp, sizeof(tmp), "#line %u \"%s\"", unsigned(i + 1), basename);
output->push_back(tmp);
}
else if (strstr(line, "#endif") || strstr(line, "#pragma"))
{
// #line seems to be ignored if preprocessor tests fail,
// so we should reapply #line after each #endif.
// Add extra offset here since we're setting #line for the line after this one.
/* #line seems to be ignored if preprocessor tests fail,
* so we should reapply #line after each #endif.
* Add extra offset here since we're setting #line
* for the line after this one.
*/
snprintf(tmp, sizeof(tmp), "#line %u \"%s\"", unsigned(i + 2), basename);
output->push_back(line);
output->push_back(tmp);
@ -140,7 +154,7 @@ static string build_stage_source(const vector<string> &lines, const char *stage)
ostringstream str;
bool active = true;
// Version header.
/* Version header. */
str << lines.front();
str << '\n';
@ -157,7 +171,7 @@ static string build_stage_source(const vector<string> &lines, const char *stage)
else if (itr->find("#pragma name ") == 0 ||
itr->find("#pragma format ") == 0)
{
// Ignore
/* Ignore */
}
else if (active)
str << *itr;
@ -253,10 +267,11 @@ static glslang_format glslang_find_format(const char *fmt)
static bool glslang_parse_meta(const vector<string> &lines, glslang_meta *meta)
{
char id[64] = {};
char id[64] = {};
char desc[64] = {};
*meta = glslang_meta{};
for (auto &line : lines)
{
if (line.find("#pragma name ") == 0)
@ -290,7 +305,8 @@ static bool glslang_parse_meta(const vector<string> &lines, glslang_meta *meta)
return param.id == id;
});
// Allow duplicate #pragma parameter, but only if they are exactly the same.
/* Allow duplicate #pragma parameter, but only
* if they are exactly the same. */
if (itr != end(meta->parameters))
{
if (itr->desc != desc ||
@ -314,13 +330,16 @@ static bool glslang_parse_meta(const vector<string> &lines, glslang_meta *meta)
}
else if (line.find("#pragma format ") == 0)
{
const char *str = NULL;
if (meta->rt_format != SLANG_FORMAT_UNKNOWN)
{
RARCH_ERR("[slang]: Trying to declare format multiple times for file.\n");
return false;
}
const char *str = line.c_str() + strlen("#pragma format ");
str = line.c_str() + strlen("#pragma format ");
while (*str == ' ')
str++;

View File

@ -23,9 +23,6 @@
#include <gfx/math/matrix_4x4.h>
#include <string/stdstring.h>
#include "../video_state_tracker.h"
#include "../../dynamic.h"
#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
@ -35,6 +32,8 @@
#endif
#include "../video_shader_driver.h"
#include "../video_state_tracker.h"
#include "../../dynamic.h"
typedef struct null_shader_data
{

View File

@ -80,7 +80,7 @@ enum slang_stage
SLANG_STAGE_FRAGMENT_MASK = 1 << 1
};
// Vulkan minimum limit.
/* Vulkan minimum limit. */
#define SLANG_NUM_BINDINGS 16
struct slang_texture_semantic_meta