Skip to content

Commit

Permalink
GSL moved from stdafx.h (#1676)
Browse files Browse the repository at this point in the history
Added GSL.h helper for correct including
  • Loading branch information
Nekotekina committed Apr 19, 2016
1 parent efc8779 commit 75fe95e
Show file tree
Hide file tree
Showing 19 changed files with 51 additions and 30 deletions.
14 changes: 14 additions & 0 deletions Utilities/GSL.h
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#define GSL_THROW_ON_CONTRACT_VIOLATION

#pragma push_macro("new")
#pragma push_macro("Expects")
#pragma push_macro("Ensures")
#undef new
#undef Expects
#undef Ensures
#include <gsl.h>
#pragma pop_macro("Ensures")
#pragma pop_macro("Expects")
#pragma pop_macro("new")
5 changes: 5 additions & 0 deletions Utilities/types.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ using s16 = std::int16_t;
using s32 = std::int32_t; using s32 = std::int32_t;
using s64 = std::int64_t; using s64 = std::int64_t;


namespace gsl
{
enum class byte : std::uint8_t;
}

// Specialization with static constexpr pair<T1, T2> map[] member expected // Specialization with static constexpr pair<T1, T2> map[] member expected
template<typename T1, typename T2> template<typename T1, typename T2>
struct bijective; struct bijective;
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ void spursSysServiceProcessRequests(SPUThread& spu, SpursKernelContext* ctxt)
bool updateWorkload = false; bool updateWorkload = false;
bool terminate = false; bool terminate = false;


vm::reservation_op(vm::cast(ctxt->spurs.addr() + offsetof(CellSpurs, wklState1), HERE), 128, [&]() vm::reservation_op(vm::cast(ctxt->spurs.addr() + OFFSET_32(CellSpurs, wklState1), HERE), 128, [&]()
{ {
auto spurs = ctxt->spurs.get_ptr_priv(); auto spurs = ctxt->spurs.get_ptr_priv();


Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/Modules/cellSysmodule.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static const char* get_module_name(u16 id)


static const char* get_module_id(u16 id) static const char* get_module_id(u16 id)
{ {
thread_local static char tls_id_name[8]; // for test static thread_local char tls_id_name[8]; // for test


switch (id) switch (id)
{ {
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/Modules/cellSysutil.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ cfg::map_entry<s32> g_cfg_sys_language(cfg::root.sys, "Language",


static const char* get_systemparam_id_name(s32 id) static const char* get_systemparam_id_name(s32 id)
{ {
thread_local static char tls_id_name[16]; // for test static thread_local char tls_id_name[16]; // for test


switch (id) switch (id)
{ {
Expand Down
3 changes: 3 additions & 0 deletions rpcs3/Emu/RSX/Common/BufferUtils.h
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,8 @@
#pragma once #pragma once

#include <vector> #include <vector>

#include "Utilities/GSL.h"
#include "Emu/Memory/vm.h" #include "Emu/Memory/vm.h"
#include "../RSXThread.h" #include "../RSXThread.h"


Expand Down
2 changes: 2 additions & 0 deletions rpcs3/Emu/RSX/Common/ProgramStateCache.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Emu/RSX/RSXVertexProgram.h" #include "Emu/RSX/RSXVertexProgram.h"
#include "Emu/Memory/vm.h" #include "Emu/Memory/vm.h"


#include "Utilities/GSL.h"


enum class SHADER_TYPE enum class SHADER_TYPE
{ {
Expand All @@ -15,6 +16,7 @@ namespace program_hash_util
{ {
// Based on // Based on
// https://github.com/AlexAltea/nucleus/blob/master/nucleus/gpu/rsx_pgraph.cpp // https://github.com/AlexAltea/nucleus/blob/master/nucleus/gpu/rsx_pgraph.cpp
// TODO: eliminate it and implement independent hash utility
union qword union qword
{ {
u64 dword[2]; u64 dword[2];
Expand Down
3 changes: 3 additions & 0 deletions rpcs3/Emu/RSX/Common/TextureUtils.h
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,9 @@
#pragma once #pragma once

#include "../RSXTexture.h" #include "../RSXTexture.h"

#include <vector> #include <vector>
#include "Utilities/GSL.h"


struct rsx_subresource_layout struct rsx_subresource_layout
{ {
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/Common/surface_store.h
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once #pragma once


#include <gsl.h> #include "Utilities/GSL.h"
#include "../GCM.h" #include "../GCM.h"
#include <list> #include <list>


Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ void GLFragmentProgram::Compile()
id = glCreateShader(GL_FRAGMENT_SHADER); id = glCreateShader(GL_FRAGMENT_SHADER);


const char* str = shader.c_str(); const char* str = shader.c_str();
const int strlen = gsl::narrow<int>(shader.length()); const int strlen = ::narrow<int>(shader.length());


glShaderSource(id, 1, &str, &strlen); glShaderSource(id, 1, &str, &strlen);
glCompileShader(id); glCompileShader(id);
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/GL/GLVertexProgram.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ void GLVertexProgram::Compile()
id = glCreateShader(GL_VERTEX_SHADER); id = glCreateShader(GL_VERTEX_SHADER);


const char* str = shader.c_str(); const char* str = shader.c_str();
const int strlen = gsl::narrow<int>(shader.length()); const int strlen = ::narrow<int>(shader.length());


glShaderSource(id, 1, &str, &strlen); glShaderSource(id, 1, &str, &strlen);
glCompileShader(id); glCompileShader(id);
Expand Down
2 changes: 2 additions & 0 deletions rpcs3/Emu/RSX/RSXThread.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "Common/BufferUtils.h" #include "Common/BufferUtils.h"
#include "rsx_methods.h" #include "rsx_methods.h"


#include "Utilities/GSL.h"

#define CMD_DEBUG 0 #define CMD_DEBUG 0


cfg::bool_entry g_cfg_rsx_write_color_buffers(cfg::root.video, "Write Color Buffers"); cfg::bool_entry g_cfg_rsx_write_color_buffers(cfg::root.video, "Write Color Buffers");
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/RSX/rsx_utils.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ namespace rsx
template<typename T> template<typename T>
void convert_linear_swizzle(void* input_pixels, void* output_pixels, u16 width, u16 height, bool input_is_swizzled) void convert_linear_swizzle(void* input_pixels, void* output_pixels, u16 width, u16 height, bool input_is_swizzled)
{ {
u16 log2width = gsl::narrow<u16>(ceil(log2(width))); u16 log2width = ::narrow<u16>(ceil(log2(width)));
u16 log2height = gsl::narrow<u16>(ceil(log2(height))); u16 log2height = ::narrow<u16>(ceil(log2(height)));


// Max mask possible for square texture // Max mask possible for square texture
u32 x_mask = 0x55555555; u32 x_mask = 0x55555555;
Expand Down
5 changes: 0 additions & 5 deletions rpcs3/GLGSRender.vcxproj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@
<Import Project="..\rpcs3_llvm.props" /> <Import Project="..\rpcs3_llvm.props" />
</ImportGroup> </ImportGroup>
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release - LLVM|x64'">
<ClCompile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="emucore.vcxproj"> <ProjectReference Include="emucore.vcxproj">
<Project>{c4a10229-4712-4bd2-b63e-50d93c67a038}</Project> <Project>{c4a10229-4712-4bd2-b63e-50d93c67a038}</Project>
Expand Down
2 changes: 2 additions & 0 deletions rpcs3/Gui/RSXDebugger.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "MemoryViewer.h" #include "MemoryViewer.h"
#include "RSXDebugger.h" #include "RSXDebugger.h"


#include "Utilities/GSL.h"

enum GCMEnumTypes enum GCMEnumTypes
{ {
CELL_GCM_ENUM, CELL_GCM_ENUM,
Expand Down
14 changes: 7 additions & 7 deletions rpcs3/Loader/PSF.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace psf
{ {
case format::string: case format::string:
case format::array: case format::array:
return std::min(m_max_size, gsl::narrow<u32>(m_value_string.size() + (m_type == format::string))); return std::min(m_max_size, ::narrow<u32>(m_value_string.size() + (m_type == format::string)));


case format::integer: case format::integer:
return SIZE_32(u32); return SIZE_32(u32);
Expand Down Expand Up @@ -157,14 +157,14 @@ namespace psf
for (const auto& entry : psf) for (const auto& entry : psf)
{ {
def_table_t index; def_table_t index;
index.key_off = gsl::narrow<u32>(key_offset); index.key_off = ::narrow<u32>(key_offset);
index.param_fmt = entry.second.type(); index.param_fmt = entry.second.type();
index.param_len = entry.second.size(); index.param_len = entry.second.size();
index.param_max = entry.second.max(); index.param_max = entry.second.max();
index.data_off = gsl::narrow<u32>(data_offset); index.data_off = ::narrow<u32>(data_offset);


// Update offsets: // Update offsets:
key_offset += gsl::narrow<u32>(entry.first.size() + 1); // key size key_offset += ::narrow<u32>(entry.first.size() + 1); // key size
data_offset += index.param_max; data_offset += index.param_max;


indices.push_back(index); indices.push_back(index);
Expand All @@ -177,9 +177,9 @@ namespace psf
header_t header; header_t header;
header.magic = "\0PSF"_u32; header.magic = "\0PSF"_u32;
header.version = 0x101; header.version = 0x101;
header.off_key_table = gsl::narrow<u32>(sizeof(header_t) + sizeof(def_table_t) * psf.size()); header.off_key_table = ::narrow<u32>(sizeof(header_t) + sizeof(def_table_t) * psf.size());
header.off_data_table = gsl::narrow<u32>(header.off_key_table + key_offset); header.off_data_table = ::narrow<u32>(header.off_key_table + key_offset);
header.entries_num = gsl::narrow<u32>(psf.size()); header.entries_num = ::narrow<u32>(psf.size());


// Save header and indices // Save header and indices
std::vector<char> result; result.reserve(header.off_data_table + data_offset); std::vector<char> result; result.reserve(header.off_data_table + data_offset);
Expand Down
1 change: 1 addition & 0 deletions rpcs3/emucore.vcxproj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@
<ClInclude Include="..\Utilities\BEType.h" /> <ClInclude Include="..\Utilities\BEType.h" />
<ClInclude Include="..\Utilities\BitField.h" /> <ClInclude Include="..\Utilities\BitField.h" />
<ClInclude Include="..\Utilities\event.h" /> <ClInclude Include="..\Utilities\event.h" />
<ClInclude Include="..\Utilities\GSL.h" />
<ClInclude Include="..\Utilities\Platform.h" /> <ClInclude Include="..\Utilities\Platform.h" />
<ClInclude Include="..\Utilities\Log.h" /> <ClInclude Include="..\Utilities\Log.h" />
<ClInclude Include="..\Utilities\File.h" /> <ClInclude Include="..\Utilities\File.h" />
Expand Down
3 changes: 3 additions & 0 deletions rpcs3/emucore.vcxproj.filters
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1588,5 +1588,8 @@
<ClInclude Include="Emu\VFS.h"> <ClInclude Include="Emu\VFS.h">
<Filter>Emu</Filter> <Filter>Emu</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Utilities\GSL.h">
<Filter>Utilities</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>
11 changes: 1 addition & 10 deletions rpcs3/stdafx.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@
#include <unordered_map> #include <unordered_map>
#include <chrono> #include <chrono>


#include "Utilities/types.h"

#include <restore_new.h>
#define GSL_THROW_ON_CONTRACT_VIOLATION
#include <gsl.h>
#include <define_new_memleakdetect.h>

#undef Expects
#undef Ensures

using namespace std::string_literals; using namespace std::string_literals;
using namespace std::chrono_literals; using namespace std::chrono_literals;


Expand All @@ -58,6 +48,7 @@ using namespace std::chrono_literals;
#define _PRGNAME_ "RPCS3" #define _PRGNAME_ "RPCS3"
#define _PRGVER_ "0.0.0.9" #define _PRGVER_ "0.0.0.9"


#include "Utilities/types.h"
#include "Utilities/Macro.h" #include "Utilities/Macro.h"
#include "Utilities/Platform.h" #include "Utilities/Platform.h"
#include "Utilities/BEType.h" #include "Utilities/BEType.h"
Expand Down

1 comment on commit 75fe95e

@C0nv3rsE
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this playable? everything runs good, but when the actual fight starts fps drops to 15-20 at max, im doing something wrong here ?

Please sign in to comment.