From 6ca9afbd577d5d5f4bb8cadf59c94180854a24b6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 12 Jan 2019 18:51:06 +0100 Subject: [PATCH] Silence more warnings with CXX_BUILD --- gfx/drivers/d3d9.c | 8 +- gfx/drivers/gdi_gfx.c | 2 +- gfx/drivers_shader/shader_vulkan.cpp | 1 + gfx/drivers_shader/slang_process.cpp | 1 + gfx/drivers_shader/slang_reflection.cpp | 1 + gfx/drivers_shader/slang_reflection.h | 148 +++++------------- gfx/drivers_shader/slang_reflection.hpp | 86 ++++++++++ libretro-common/formats/libchdr/libchdr_chd.c | 2 +- menu/drivers_display/menu_display_gdi.c | 12 +- 9 files changed, 142 insertions(+), 119 deletions(-) create mode 100644 gfx/drivers_shader/slang_reflection.hpp diff --git a/gfx/drivers/d3d9.c b/gfx/drivers/d3d9.c index c5fc42bf70..079af6665a 100644 --- a/gfx/drivers/d3d9.c +++ b/gfx/drivers/d3d9.c @@ -1174,11 +1174,13 @@ static void d3d9_set_osd_msg(void *data, { d3d9_video_t *d3d = (d3d9_video_t*)data; LPDIRECT3DDEVICE9 dev = d3d->dev; + const struct font_params *d3d_font_params = (const + struct font_params*)params; - d3d9_set_font_rect(d3d, params); + d3d9_set_font_rect(d3d, d3d_font_params); d3d9_begin_scene(dev); font_driver_render_msg(video_info, font, - msg, (const struct font_params *)params); + msg, d3d_font_params); d3d9_end_scene(dev); } @@ -1733,7 +1735,7 @@ static bool d3d9_read_viewport(void *data, uint8_t *buffer, bool is_idle) !d3d9_device_create_offscreen_plain_surface(d3dr, width, height, d3d9_get_xrgb8888_format(), D3DPOOL_SYSTEMMEM, (void**)&dest, NULL) || - !d3d9_device_get_render_target_data(d3dr, (void*)target, (void*)dest) + !d3d9_device_get_render_target_data(d3dr, target, dest) ) { ret = false; diff --git a/gfx/drivers/gdi_gfx.c b/gfx/drivers/gdi_gfx.c index 360b341773..034a6db400 100644 --- a/gfx/drivers/gdi_gfx.c +++ b/gfx/drivers/gdi_gfx.c @@ -585,7 +585,7 @@ static uintptr_t gdi_load_texture(void *video_data, void *data, if (!image || image->width > 2048 || image->height > 2048) return 0; - texture = calloc(1, sizeof(*texture)); + texture = (gdi_texture_t*)calloc(1, sizeof(*texture)); if (!texture) return 0; diff --git a/gfx/drivers_shader/shader_vulkan.cpp b/gfx/drivers_shader/shader_vulkan.cpp index 022d4c9fb0..167ad161ba 100644 --- a/gfx/drivers_shader/shader_vulkan.cpp +++ b/gfx/drivers_shader/shader_vulkan.cpp @@ -29,6 +29,7 @@ #include #include "slang_reflection.h" +#include "slang_reflection.hpp" #include "../video_driver.h" #include "../../verbosity.h" diff --git a/gfx/drivers_shader/slang_process.cpp b/gfx/drivers_shader/slang_process.cpp index 3d9f1179f2..5d9d91b563 100644 --- a/gfx/drivers_shader/slang_process.cpp +++ b/gfx/drivers_shader/slang_process.cpp @@ -12,6 +12,7 @@ #include "glslang_util.h" #include "slang_preprocess.h" #include "slang_reflection.h" +#include "slang_reflection.hpp" #include "slang_process.h" #include "../../verbosity.h" diff --git a/gfx/drivers_shader/slang_reflection.cpp b/gfx/drivers_shader/slang_reflection.cpp index 74e99774f2..af4aaa1fe8 100644 --- a/gfx/drivers_shader/slang_reflection.cpp +++ b/gfx/drivers_shader/slang_reflection.cpp @@ -15,6 +15,7 @@ #include "spirv_cross.hpp" #include "slang_reflection.h" +#include "slang_reflection.hpp" #include #include #include diff --git a/gfx/drivers_shader/slang_reflection.h b/gfx/drivers_shader/slang_reflection.h index 0d013c37a6..014d5b5caa 100644 --- a/gfx/drivers_shader/slang_reflection.h +++ b/gfx/drivers_shader/slang_reflection.h @@ -16,65 +16,70 @@ #ifndef SLANG_REFLECTION_H_ #define SLANG_REFLECTION_H_ -// Textures with built-in meaning. +/* Textures with built-in meaning. */ enum slang_texture_semantic { - // The input texture to the filter chain. - // Canonical name: "Original". - SLANG_TEXTURE_SEMANTIC_ORIGINAL = 0, + /* The input texture to the filter chain. + * Canonical name: "Original". */ + SLANG_TEXTURE_SEMANTIC_ORIGINAL = 0, - // The output from pass N - 1 if executing pass N, or ORIGINAL - // if pass #0 is executed. - // Canonical name: "Source". - SLANG_TEXTURE_SEMANTIC_SOURCE = 1, + /* The output from pass N - 1 if executing pass N, or ORIGINAL + * if pass #0 is executed. + * Canonical name: "Source". + */ + SLANG_TEXTURE_SEMANTIC_SOURCE = 1, - // The original inputs with a history back in time. - // Canonical name: "OriginalHistory#", e.g. "OriginalHistory2" <- Two frames back. - // "OriginalHistory0" is an alias for SEMANTIC_ORIGINAL. - // Size name: "OriginalHistorySize#". + /* The original inputs with a history back in time. + * Canonical name: "OriginalHistory#", e.g. "OriginalHistory2" <- Two frames back. + * "OriginalHistory0" is an alias for SEMANTIC_ORIGINAL. + * Size name: "OriginalHistorySize#". + */ SLANG_TEXTURE_SEMANTIC_ORIGINAL_HISTORY = 2, - // The output from pass #N, where pass #0 is the first pass. - // Canonical name: "PassOutput#", e.g. "PassOutput3". - // Size name: "PassOutputSize#". - SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT = 3, + /* The output from pass #N, where pass #0 is the first pass. + * Canonical name: "PassOutput#", e.g. "PassOutput3". + * Size name: "PassOutputSize#". + */ + SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT = 3, - // The output from pass #N, one frame ago where pass #0 is the first pass. - // It is not valid to use the pass feedback from a pass which is not offscreen. - // Canonical name: "PassFeedback#", e.g. "PassFeedback2". - SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK = 4, + /* The output from pass #N, one frame ago where pass #0 is the first pass. + * It is not valid to use the pass feedback from a pass which is not offscreen. + * Canonical name: "PassFeedback#", e.g. "PassFeedback2". + */ + SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK = 4, - // Inputs from static textures, defined by the user. - // There is no canonical name, and the only way to use these semantics are by - // remapping. - SLANG_TEXTURE_SEMANTIC_USER = 5, + /* Inputs from static textures, defined by the user. + * There is no canonical name, and the only way to use these semantics are by + * remapping. + */ + SLANG_TEXTURE_SEMANTIC_USER = 5, SLANG_NUM_TEXTURE_SEMANTICS, - SLANG_INVALID_TEXTURE_SEMANTIC = -1 + SLANG_INVALID_TEXTURE_SEMANTIC = -1 }; enum slang_semantic { - // mat4, MVP - SLANG_SEMANTIC_MVP = 0, - // vec4, viewport size of current pass - SLANG_SEMANTIC_OUTPUT = 1, - // vec4, viewport size of final pass - SLANG_SEMANTIC_FINAL_VIEWPORT = 2, - // uint, frame count with modulo - SLANG_SEMANTIC_FRAME_COUNT = 3, + /* mat4, MVP */ + SLANG_SEMANTIC_MVP = 0, + /* vec4, viewport size of current pass */ + SLANG_SEMANTIC_OUTPUT = 1, + /* vec4, viewport size of final pass */ + SLANG_SEMANTIC_FINAL_VIEWPORT = 2, + /* uint, frame count with modulo */ + SLANG_SEMANTIC_FRAME_COUNT = 3, SLANG_NUM_BASE_SEMANTICS, - // float, user defined parameter, arrayed + /* float, user defined parameter, arrayed */ SLANG_SEMANTIC_FLOAT_PARAMETER = 4, SLANG_NUM_SEMANTICS, - SLANG_INVALID_SEMANTIC = -1 + SLANG_INVALID_SEMANTIC = -1 }; enum slang_stage { - SLANG_STAGE_VERTEX_MASK = 1 << 0, + SLANG_STAGE_VERTEX_MASK = 1 << 0, SLANG_STAGE_FRAGMENT_MASK = 1 << 1 }; @@ -88,75 +93,4 @@ enum slang_constant_buffer /* Vulkan minimum limit. */ #define SLANG_NUM_BINDINGS 16 -#ifdef __cplusplus - -#include -#include -#include -#include - -struct slang_texture_semantic_meta -{ - size_t ubo_offset = 0; - size_t push_constant_offset = 0; - unsigned binding = 0; - uint32_t stage_mask = 0; - - bool texture = false; - bool uniform = false; - bool push_constant = false; -}; - -struct slang_semantic_meta -{ - size_t ubo_offset = 0; - size_t push_constant_offset = 0; - unsigned num_components = 0; - bool uniform = false; - bool push_constant = false; -}; - -struct slang_texture_semantic_map -{ - slang_texture_semantic semantic; - unsigned index; -}; - -struct slang_semantic_map -{ - slang_semantic semantic; - unsigned index; -}; - -struct slang_reflection -{ - slang_reflection(); - - size_t ubo_size = 0; - size_t push_constant_size = 0; - - unsigned ubo_binding = 0; - uint32_t ubo_stage_mask = 0; - uint32_t push_constant_stage_mask = 0; - - std::vector semantic_textures[SLANG_NUM_TEXTURE_SEMANTICS]; - slang_semantic_meta semantics[SLANG_NUM_SEMANTICS]; - std::vector semantic_float_parameters; - - const std::unordered_map *texture_semantic_map = nullptr; - const std::unordered_map *texture_semantic_uniform_map = nullptr; - const std::unordered_map *semantic_map = nullptr; - unsigned pass_number = 0; -}; - -bool slang_reflect_spirv(const std::vector &vertex, - const std::vector &fragment, - slang_reflection *reflection); - -bool slang_reflect(const spirv_cross::Compiler &vertex_compiler, const spirv_cross::Compiler &fragment_compiler, - const spirv_cross::ShaderResources &vertex, const spirv_cross::ShaderResources &fragment, - slang_reflection *reflection); - #endif -#endif - diff --git a/gfx/drivers_shader/slang_reflection.hpp b/gfx/drivers_shader/slang_reflection.hpp new file mode 100644 index 0000000000..c424899317 --- /dev/null +++ b/gfx/drivers_shader/slang_reflection.hpp @@ -0,0 +1,86 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2019 - Hans-Kristian Arntzen + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#ifndef SLANG_REFLECTION_HPP_ +#define SLANG_REFLECTION_HPP_ + +#include +#include +#include +#include + +struct slang_texture_semantic_meta +{ + size_t ubo_offset = 0; + size_t push_constant_offset = 0; + unsigned binding = 0; + uint32_t stage_mask = 0; + + bool texture = false; + bool uniform = false; + bool push_constant = false; +}; + +struct slang_semantic_meta +{ + size_t ubo_offset = 0; + size_t push_constant_offset = 0; + unsigned num_components = 0; + bool uniform = false; + bool push_constant = false; +}; + +struct slang_texture_semantic_map +{ + slang_texture_semantic semantic; + unsigned index; +}; + +struct slang_semantic_map +{ + slang_semantic semantic; + unsigned index; +}; + +struct slang_reflection +{ + slang_reflection(); + + size_t ubo_size = 0; + size_t push_constant_size = 0; + + unsigned ubo_binding = 0; + uint32_t ubo_stage_mask = 0; + uint32_t push_constant_stage_mask = 0; + + std::vector semantic_textures[SLANG_NUM_TEXTURE_SEMANTICS]; + slang_semantic_meta semantics[SLANG_NUM_SEMANTICS]; + std::vector semantic_float_parameters; + + const std::unordered_map *texture_semantic_map = nullptr; + const std::unordered_map *texture_semantic_uniform_map = nullptr; + const std::unordered_map *semantic_map = nullptr; + unsigned pass_number = 0; +}; + +bool slang_reflect_spirv(const std::vector &vertex, + const std::vector &fragment, + slang_reflection *reflection); + +bool slang_reflect(const spirv_cross::Compiler &vertex_compiler, const spirv_cross::Compiler &fragment_compiler, + const spirv_cross::ShaderResources &vertex, const spirv_cross::ShaderResources &fragment, + slang_reflection *reflection); + +#endif diff --git a/libretro-common/formats/libchdr/libchdr_chd.c b/libretro-common/formats/libchdr/libchdr_chd.c index 9d41cb44bc..ddb951241e 100644 --- a/libretro-common/formats/libchdr/libchdr_chd.c +++ b/libretro-common/formats/libchdr/libchdr_chd.c @@ -986,7 +986,7 @@ chd_error chd_precache(chd_file *chd) size = filestream_tell(chd->file); if (size <= 0) return CHDERR_INVALID_DATA; - chd->file_cache = malloc(size); + chd->file_cache = (UINT8*)malloc(size); if (chd->file_cache == NULL) return CHDERR_OUT_OF_MEMORY; filestream_seek(chd->file, 0, SEEK_SET); diff --git a/menu/drivers_display/menu_display_gdi.c b/menu/drivers_display/menu_display_gdi.c index 15207b867f..d2fe232220 100644 --- a/menu/drivers_display/menu_display_gdi.c +++ b/menu/drivers_display/menu_display_gdi.c @@ -75,22 +75,20 @@ static void menu_display_gdi_draw(menu_display_ctx_draw_t *draw, #endif if (!gdi->texDC) - gdi->texDC = CreateCompatibleDC(gdi->winDC); + gdi->texDC = CreateCompatibleDC(gdi->winDC); if (texture->bmp) - { - texture->bmp_old = SelectObject(gdi->texDC, texture->bmp); - } + texture->bmp_old = (HBITMAP)SelectObject(gdi->texDC, texture->bmp); else { /* scale texture data into a bitmap we can easily blit later */ - texture->bmp = CreateCompatibleBitmap(gdi->winDC, draw->width, draw->height); - texture->bmp_old = SelectObject(gdi->texDC, texture->bmp); + texture->bmp = CreateCompatibleBitmap(gdi->winDC, draw->width, draw->height); + texture->bmp_old = (HBITMAP)SelectObject(gdi->texDC, texture->bmp); StretchDIBits(gdi->texDC, 0, 0, draw->width, draw->height, 0, 0, texture->width, texture->height, texture->data, &info, DIB_RGB_COLORS, SRCCOPY); } - gdi->bmp_old = SelectObject(gdi->memDC, gdi->bmp); + gdi->bmp_old = (HBITMAP)SelectObject(gdi->memDC, gdi->bmp); #if _WIN32_WINNT >= 0x0410 /* Win98 */ blend.BlendOp = AC_SRC_OVER;