diff options
| author | shuffle2 <godisgovernment@gmail.com> | 2017-06-07 20:33:54 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-07 20:33:54 -0700 |
| commit | b11d722eeda67bc498f7bf727649fb4ae4e5f997 (patch) | |
| tree | 597b9596564442ac1c125f5f7332ffc6ec97ce03 /Source/Core/VideoCommon | |
| parent | e6aa118f2111351c7fb38a611f3523793927addb (diff) | |
| parent | fd166032abec349b9fae7240830133bf7e0c77b5 (diff) | |
Merge pull request #5572 from shuffle2/msvc-w4
msvc: use /W4 (and fixes to make it work)
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/AVIDump.cpp | 16 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Fifo.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/ImageWrite.cpp | 31 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/IndexGenerator.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/TextureCacheBase.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VertexLoaderBase.h | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VideoConfig.h | 4 |
7 files changed, 40 insertions, 19 deletions
diff --git a/Source/Core/VideoCommon/AVIDump.cpp b/Source/Core/VideoCommon/AVIDump.cpp index dc4e806f6a..6a7590f034 100644 --- a/Source/Core/VideoCommon/AVIDump.cpp +++ b/Source/Core/VideoCommon/AVIDump.cpp @@ -159,8 +159,9 @@ bool AVIDump::CreateVideoFile() const AVCodec* codec = nullptr; - if (!(codec = avcodec_find_encoder(codec_id)) || - !(s_codec_context = avcodec_alloc_context3(codec))) + codec = avcodec_find_encoder(codec_id); + s_codec_context = avcodec_alloc_context3(codec); + if (!codec || !s_codec_context) { ERROR_LOG(VIDEO, "Could not find encoder or allocate codec context"); return false; @@ -203,8 +204,8 @@ bool AVIDump::CreateVideoFile() return false; #endif - if (!(s_stream = avformat_new_stream(s_format_context, codec)) || - !AVStreamCopyContext(s_stream, s_codec_context)) + s_stream = avformat_new_stream(s_format_context, codec); + if (!s_stream || !AVStreamCopyContext(s_stream, s_codec_context)) { ERROR_LOG(VIDEO, "Could not create stream"); return false; @@ -299,9 +300,10 @@ void AVIDump::AddFrame(const u8* data, int width, int height, int stride, const s_src_frame->height = s_height; // Convert image from {BGR24, RGBA} to desired pixel format - if ((s_sws_context = - sws_getCachedContext(s_sws_context, width, height, s_pix_fmt, s_width, s_height, - s_codec_context->pix_fmt, SWS_BICUBIC, nullptr, nullptr, nullptr))) + s_sws_context = + sws_getCachedContext(s_sws_context, width, height, s_pix_fmt, s_width, s_height, + s_codec_context->pix_fmt, SWS_BICUBIC, nullptr, nullptr, nullptr); + if (s_sws_context) { sws_scale(s_sws_context, s_src_frame->data, s_src_frame->linesize, 0, height, s_scaled_frame->data, s_scaled_frame->linesize); diff --git a/Source/Core/VideoCommon/Fifo.cpp b/Source/Core/VideoCommon/Fifo.cpp index 377d7d5010..cedbea5432 100644 --- a/Source/Core/VideoCommon/Fifo.cpp +++ b/Source/Core/VideoCommon/Fifo.cpp @@ -353,7 +353,7 @@ void RunGpuLoop() DataReader(s_video_buffer_read_ptr, write_ptr), &cyclesExecuted, false); Common::AtomicStore(fifo.CPReadPointer, readPtr); - Common::AtomicAdd(fifo.CPReadWriteDistance, -32); + Common::AtomicAdd(fifo.CPReadWriteDistance, static_cast<u32>(-32)); if ((write_ptr - s_video_buffer_read_ptr) == 0) Common::AtomicStore(fifo.SafeCPReadPointer, fifo.CPReadPointer); diff --git a/Source/Core/VideoCommon/ImageWrite.cpp b/Source/Core/VideoCommon/ImageWrite.cpp index 6156ca2cb1..e7930a18c6 100644 --- a/Source/Core/VideoCommon/ImageWrite.cpp +++ b/Source/Core/VideoCommon/ImageWrite.cpp @@ -21,6 +21,11 @@ bool SaveData(const std::string& filename, const std::string& data) return true; } +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4611) +#endif + /* TextureToPng @@ -31,20 +36,16 @@ row_stride: Determines the amount of bytes per row of pixels. bool TextureToPng(const u8* data, int row_stride, const std::string& filename, int width, int height, bool saveAlpha) { - bool success = false; - if (!data) return false; + bool success = false; char title[] = "Dolphin Screenshot"; char title_key[] = "Title"; png_structp png_ptr = nullptr; png_infop info_ptr = nullptr; std::vector<u8> buffer; - if (!saveAlpha) - buffer.resize(width * 4); - // Open file for writing (binary mode) File::IOFile fp(filename, "wb"); if (!fp.IsOpen()) @@ -70,13 +71,22 @@ bool TextureToPng(const u8* data, int row_stride, const std::string& filename, i goto finalise; } - // Setup Exception handling + // Classical libpng error handling uses longjmp to do C-style unwind. + // Modern libpng does support a user callback, but it's required to operate + // in the same way (just gives a chance to do stuff before the longjmp). + // Instead of futzing with it, we use gotos specifically so the compiler + // will still generate proper destructor calls for us (hopefully). + // We also do not use any local variables outside the region longjmp may + // have been called from if they were modified inside that region (they + // would need to be volatile). if (setjmp(png_jmpbuf(png_ptr))) { PanicAlert("Screenshot failed: Error during PNG creation"); goto finalise; } + // Begin region which may call longjmp + png_init_io(png_ptr, fp.GetHandle()); // Write header (8 bit color depth) @@ -91,6 +101,9 @@ bool TextureToPng(const u8* data, int row_stride, const std::string& filename, i png_write_info(png_ptr, info_ptr); + if (!saveAlpha) + buffer.resize(width * 4); + // Write image data for (auto y = 0; y < height; ++y) { @@ -114,6 +127,8 @@ bool TextureToPng(const u8* data, int row_stride, const std::string& filename, i // End write png_write_end(png_ptr, nullptr); + // End region which may call longjmp + success = true; finalise: @@ -124,3 +139,7 @@ finalise: return success; } + +#ifdef _MSC_VER +#pragma warning(pop) +#endif diff --git a/Source/Core/VideoCommon/IndexGenerator.cpp b/Source/Core/VideoCommon/IndexGenerator.cpp index 79dbc92597..74f6a8a728 100644 --- a/Source/Core/VideoCommon/IndexGenerator.cpp +++ b/Source/Core/VideoCommon/IndexGenerator.cpp @@ -16,7 +16,7 @@ u16* IndexGenerator::index_buffer_current; u16* IndexGenerator::BASEIptr; u32 IndexGenerator::base_index; -static const u16 s_primitive_restart = -1; +static const u16 s_primitive_restart = UINT16_MAX; static u16* (*primitive_table[8])(u16*, u32, u32); diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 613f2dfed9..72978f6752 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -994,7 +994,7 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFo float* const ColorMask = colmat + 20; ColorMask[0] = ColorMask[1] = ColorMask[2] = ColorMask[3] = 255.0f; ColorMask[4] = ColorMask[5] = ColorMask[6] = ColorMask[7] = 1.0f / 255.0f; - unsigned int cbufid = -1; + unsigned int cbufid = UINT_MAX; u32 srcFormat = bpmem.zcontrol.pixel_format; bool efbHasAlpha = srcFormat == PEControl::RGBA6_Z24; diff --git a/Source/Core/VideoCommon/VertexLoaderBase.h b/Source/Core/VideoCommon/VertexLoaderBase.h index a895300466..509ccb4310 100644 --- a/Source/Core/VideoCommon/VertexLoaderBase.h +++ b/Source/Core/VideoCommon/VertexLoaderBase.h @@ -36,7 +36,7 @@ public: private: size_t CalculateHash() const { - size_t h = -1; + size_t h = SIZE_MAX; for (auto word : vid) { diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index 707afae84c..03d102eb62 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -70,7 +70,7 @@ struct VideoConfig final bool bShaderCache; // Enhancements - int iMultisamples; + u32 iMultisamples; bool bSSAA; int iEFBScale; bool bForceFiltering; @@ -167,7 +167,7 @@ struct VideoConfig final APIType api_type; std::vector<std::string> Adapters; // for D3D - std::vector<int> AAModes; + std::vector<u32> AAModes; // TODO: merge AdapterName and Adapters array std::string AdapterName; // for OpenGL |
