Commit Graph

1528 Commits

Author SHA1 Message Date
Stenzek 2492f196a7 TextureCache: Fix incomplete GPU texture decoding of non-square mips 2017-04-07 23:03:14 +10:00
Lioncash f7a2f6ad01 FileSearch: Namespace functions under the Common namespace 2017-04-07 01:02:14 -04:00
Stenzek 97dc773a3e D3D: Drop redundant interface TextureEncoder 2017-04-04 22:57:23 +10:00
Stenzek 739aced97c Vulkan: Implement compute-shader based GPU texture decoding 2017-04-01 12:32:57 +10:00
Stenzek 5fbc63fbcf Vulkan: Compute shader support 2017-04-01 12:32:57 +10:00
Stenzek 02f887ede0 OGL: Add GPUTimer class for measuring execution time of a draw/dispatch 2017-04-01 12:32:57 +10:00
Stenzek b01bcb80f4 OGL: Implement GPU texture decoding backend 2017-04-01 12:32:56 +10:00
Stenzek 82fd984f3e VideoBackends: Add configuration field for GPU texture decoding 2017-04-01 12:32:05 +10:00
Stenzek abc662d69c OGL: Support compute shaders and emitting GLSL 4.3
This also changes bSupportsEarlyFragmentTests to
bSupportsImageLoadStore, as it is used for both.
2017-04-01 12:31:41 +10:00
Stenzek b987f220e1 VideoBackends: Add support flag for compute shaders 2017-04-01 12:31:41 +10:00
Stenzek a8876a29fe OGL: Use ARB_texture_storage to allocate TextureCache entries
This ensures that they are complete textures by decoding time, as when
using compute shaders we write directly to the destination texture.
2017-04-01 12:31:41 +10:00
Stenzek f8059eae43 OGL: Fix render-target texture mipmap allocation
The loop was allocating one-too-many levels, as well as incorrect sizes
for each level. Probably not an issue as mipmapped render targets aren't
used, but the logic should be correct anyway.
2017-04-01 12:31:40 +10:00
Stenzek 5326a18fdf OGL: Fix MSAA being forced to 1x
This was a regression from the remove-everything-static-from-renderer
PR. As the comment indicates, it would be nice to move all of this logic
out of the Renderer constructor, but this is a much larger change.
2017-03-31 21:55:26 +10:00
Vincent Duvert bbb5945375 OGL: Fix texture_type checks in CreateTexture
The FrameBufferManager::CreateTexture (from the OpenGL backend) method introduced by commit 69cedf41 incorrectly compares the texture variable (which contains a name provided by glGenTextures) against GL_TEXTURE_2D_MULTISAMPLE_ARRAY and GL_TEXTURE_2D_MULTISAMPLE.
It should instead use the texture_type variable for this (as done in the first branch of the if).
2017-03-17 23:53:56 +01:00
Michael Maltese 134317e07f videoconfig: add BBoxPreferStencilImplementation
@JMC47 requested this to be able to do performance comparisons.
2017-03-15 17:41:33 -07:00
Michael Maltese 53224d41d0 OGL: only create stencil buffer when needed 2017-03-15 17:41:33 -07:00
Michael Maltese ba6e917b49 OGL: implement Bounding Box on systems w/o SSBO
This commit should have zero performance effect if SSBOs are supported.

If they aren't (e.g. on all Macs), this commit alters FramebufferManager
to attach a new stencil buffer and VertexManager to draw to it when
bounding box is active. `BBoxRead` gets the pixel data from the buffer
and dumbly loops through it to find the bounding box.

This patch can run Paper Mario: The Thousand-Year Door at almost full
speed (50–60 FPS) without Dual-Core enabled for all common bounding
box-using actions I tested (going through pipes, Plane Mode, Paper
Mode, Prof. Frankly's gate, combat, walking around the overworld, etc.)
on my computer (macOS 10.12.3, 2.8 GHz Intel Core i7, 16 GB 1600 MHz
DDR3, and Intel Iris 1536 MB).

A few more demanding scenes (e.g. the self-building bridge on the way
to Petalburg) slow to ~15% of their speed without this patch (though
they don't run quite at full speed even on master). The slowdown is
caused almost solely by `glReadPixels` in `OGL::BoundingBox::Get`.

Other implementation ideas:

- Use a stencil buffer that's separate from the depth buffer. This would
  require ARB_texture_stencil8 / OpenGL 4.4, which isn't available on
  macOS.

- Use `glGetTexImage` instead of `glReadPixels`. This is ~5 FPS slower
  on my computer, presumably because it has to transfer the entire
  combined depth-stencil buffer instead of only the stencil data.
  Getting only stencil data from `glGetTexImage` requires
  ARB_texture_stencil8 / OpenGL 4.4, which (again) is not available on
  macOS.

- Don't use a PBO, and use `glReadPixels` synchronously. This has no
  visible performance effect on my computer, and is theoretically
  slower.
2017-03-15 17:41:32 -07:00
Michael Maltese 56fe938366 extract OGL::FramebufferManager::BindLayeredTexture 2017-03-15 17:20:47 -07:00
Michael Maltese 69cedf4144 extract OGL::FramebufferManager::CreateTexture 2017-03-15 17:20:47 -07:00
Michael Maltese de940a5fd6 VideoConfig: add bSupportsFragmentStoresAndAtomics 2017-03-15 17:20:47 -07:00
Markus Wick 31bb41c532 Merge pull request #4973 from z0z0z/master
Disable pinned memory for AMD mesa drivers
2017-03-14 10:02:05 +01:00
Jules Blok 0a2b58c896 OGL: Remove support for NV_depth_buffer_float.
We can't clamp the depth values to the 24-bit range while this extension is active.
2017-03-14 01:02:13 +01:00
Stenzek 27d7a1646c Merge pull request #5065 from JosJuice/character
Fix issue 10146 (compilation issue because of colliding defines)
2017-03-11 18:26:26 +10:00
JosJuice 40e707348c Fix issue 10146 (compilation issue because of colliding defines) 2017-03-11 08:59:14 +01:00
Markus Wick e99cd57eb3 Merge pull request #4935 from Armada651/depth-range-fix
VideoBackends: Set the maximum range when the depth range is oversized.
2017-03-10 18:05:52 +01:00
Stenzek 42993eeabc D3D11: Fix error on startup with >2.5xIR selected 2017-03-10 23:41:20 +10:00
Markus Wick ef74c5eabd Merge pull request #5051 from stenzek/renderer-fixes
VideoBackends: Fix crashes introduced by #4999
2017-03-09 21:06:50 +01:00
JosJuice ced1614cac Unify the way of setting game ID, title ID, revision
The existing code from ConfigManager, ES and MIOS is merged
into a new set of functions called SetRunningGameMetadata.
2017-03-09 15:34:14 +01:00
Stenzek 2cd240af0d VideoBackends: Move max texture size to VideoConfig
This stops the virtual method call from within the Renderer constructor.

The initialization here for GL had to be moved to VideoBackend, as the
Renderer constructor will not have been executed before the value is
required.
2017-03-10 00:04:13 +10:00
Markus Wick 489d90b6f3 Merge pull request #4999 from stenzek/renderer-statics
VideoCommon: Eliminate static state in Renderer
2017-03-08 11:02:20 +01:00
Mat M 7fa14169e9 Merge pull request #5007 from lioncash/swap
Common: Move byte swapping utilities into their own header
2017-03-05 09:45:29 -05:00
Markus Wick 7304cb0f8e Merge pull request #5011 from stenzek/d3d-texture-corruption
D3D11: Use default usage for TextureCache entries
2017-03-04 15:55:58 +01:00
Stenzek 725d5bc3a1 D3D11: Drop unused method ReplaceRGBATexture2D 2017-03-04 22:37:10 +10:00
Stenzek 526fa9bc85 D3D11: Use D3D11_USAGE_DEFAULT for all TextureCache textures 2017-03-04 22:36:33 +10:00
Stenzek 4cea9a2f99 Vulkan: Fix underflow in StreamBuffer::WaitForClearSpace
This could cause the assertion on line 212 to fail when uploading large
amounts of data in between command buffer executions.
2017-03-04 18:07:04 +10:00
Stenzek 00a0a91513 VideoCommon: Move last EFB scale handling to CalculateTargetSize 2017-03-04 16:53:07 +10:00
Stenzek afc25fdca0 VideoCommon: Rename Renderer s_ prefixes to m_ 2017-03-04 16:42:21 +10:00
Stenzek 238a70b006 VideoCommon: Move some common initialization logic to RenderBase 2017-03-04 16:42:16 +10:00
Stenzek 277829d842 VideoCommon: Eliminate static state in Renderer 2017-03-04 16:39:50 +10:00
Lioncash 552c0d8404 Common: Move byte swapping utilities into their own header
This moves all the byte swapping utilities into a header named Swap.h.

A dedicated header is much more preferable here due to the size of the
code itself. In general usage throughout the codebase, CommonFuncs.h was
generally only included for these functions anyway. These being in their
own header avoids dumping the lesser used utilities into scope. As well
as providing a localized area for more utilities related to byte
swapping in the future (should they be needed). This also makes it nicer
to identify which files depend on the byte swapping utilities in
particular.

Since this is a completely new header, moving the code uncovered a few
indirect includes, as well as making some other inclusions unnecessary.
2017-03-03 17:18:18 -05:00
Stenzek 2fd77895a2 Vulkan: Fix issue where target rectangle changes weren't detected
This was causing issues when toggling the crop setting, as well as some
widescreen hacks.
2017-03-02 21:53:42 +10:00
Stenzek 3390e6f258 Merge pull request #4993 from ligfx/fixsonicadventure2
OGL SetBlendMode: always set blend equation and func
2017-03-02 21:30:10 +10:00
Lioncash ee61bd6f2e CMakeLists: Normalize whitespace
Normalizes tabs to spaces to follow our codebase's indentation style.
2017-03-01 14:53:23 -05:00
Michael Maltese db1d826ac3 OGL SetBlendMode: always set blend equation and func
Before #4581, an invocation of `SetBlendMode` could invoke
`glBlendEquationSeparate` and `glBlendFuncSeparate` even when it was
setting `glDisable(GL_BLEND)`. I couldn't figure out how to map the old
behavior over to the new BlendingState code, so I changed it to always
call the two blend functions.

Fixes https://bugs.dolphin-emu.org/issues/10120 : "Sonic Adventure 2
Battle: graphics crash when loading first Dark level".
2017-03-01 00:49:14 -08:00
z0z0z 005e6796b8 Disable pinned memory for AMD mesa drivers 2017-02-26 10:49:28 -05:00
Jules Blok a15555fe03 VideoBackends: Use vertex shader depth range if ztexture is used. 2017-02-26 11:34:48 +01:00
Jules Blok bde8126913 VideoBackends: Remove depth range clamping hacks.
Oversized depth ranges are handled correctly now, we don't need to hack around them with clamps anymore.
2017-02-24 14:54:20 +01:00
Jules Blok 94522d4cf3 OGL: Add support for glDepthRangedNV to handle oversized depth ranges. 2017-02-24 14:54:16 +01:00
Jules Blok 28e6e259ed VideoBackends: Set the maximum range when the depth range is oversized.
The depth values generated by the vertex shader need to be clamped correctly.
2017-02-21 02:57:23 +01:00
Jules Blok 21967b1f6e VideoBackends: Add a developer option to disable the shader cache.
Makes it easier to disable the cache while working on the shaders.
2017-02-19 12:05:44 +01:00
Stenzek b8eb1080ce Merge pull request #4924 from stenzek/vulkan-list-restart
Vulkan: Fix GPU hangs on AMD Polaris
2017-02-18 21:58:30 +10:00
Lioncash 1fa81f24d3 VertexManagerBase: Make CreateNativeVertexFormat return a unique_ptr
Much safer as opposed to just returning raw allocated memory.
2017-02-18 03:16:24 -05:00
Stenzek 50fa135594 Vulkan: Handle BUG_PRIMITIVE_RESTART 2017-02-18 15:07:34 +10:00
Stenzek 4094268009 Vulkan: Use TRIANGLE_LIST when primitive restart is not supported 2017-02-18 15:07:33 +10:00
Stenzek 6965dc0481 Vulkan: Don't enable primitive restart on list topologies 2017-02-18 15:07:32 +10:00
Phil Christensen 2ed61b0ee1 C++ conformance fixes (MSVC /permissive-)
We (the Microsoft C++ team) use the dolphin project as part of our "Real world code" tests.
I noticed a few issues in windows specific code when building dolphin with the MSVC compiler
in its conformance mode (/permissive-).  For more information on /permissive- see our blog
https://blogs.msdn.microsoft.com/vcblog/2016/11/16/permissive-switch/.

These changes are to address 3 different types of issues:

1) Use of qualified names in member declarations

    struct A {
        void A::f() { } // error C4596: illegal qualified name in member declaration
                        // remove redundant 'A::' to fix
    };

2) Binding a non-const reference to a temporary

    struct S{};
  
    // If arg is in 'in' parameter, then it should be made const.
    void func(S& arg){}
  
    int main() {
      //error C2664: 'void func(S &)': cannot convert argument 1 from 'S' to 'S &'
      //note: A non-const reference may only be bound to an lvalue
      func( S() );
   
      //Work around this by creating a local, and using it to call the function
      S s;
      func( s );
    }

3) Add missing #include <intrin.h>

Because of the workaround you are using in the code you will need to include
this.  This is because of changes in the libraries and not /permissive-
2017-02-15 20:37:04 -08:00
Matthew Parlane 691abc223b Merge pull request #4859 from lioncash/opcodedecoder
OpcodeDecoding: Convert #defines into enum constants
2017-02-08 18:12:11 +13:00
Lioncash d9d069e024 OpcodeDecoding: Convert #defines into enum constants
Gets several constants out of global scope.
2017-02-08 00:05:17 -05:00
Florent Castelli 8c82607c95 cmake: Don't use unqualified target_link_libraries
You can't mix unqualified and qualified link libraries (PUBLIC / PRIVATE).
Use the modern form.
2017-02-08 03:07:43 +01:00
Lioncash c85e0a2586 FramebufferManagerBase: Return a std::pair from GetTargetSize
Keeps associated data together. It also eliminates the possibility of out
parameters not being initialized properly. For example, consider the
following example:

-- some FramebufferManager implementation --

void FBMgrImpl::GetTargetSize(u32* width, u32* height) override
{
  // Do nothing
}

-- somewhere else where the function is used --

u32 width, height;
framebuffer_manager_instance->GetTargetSize(&width, &height);

if (texture_width != width) <-- Uninitialized variable usage
{
  ...
}

It makes it much more obvious to spot any initialization issues, because
it requires something to be returned, as opposed to allowing an
implementation to just not do anything.
2017-02-03 15:27:53 -05:00
Lioncash a30c653f3d D3D: Add CommonTypes include to D3DTexture.h
Resolves a compile error on the Windows CMake build.
2017-02-03 12:07:53 -05:00
Lioncash 468f623d27 ShaderGenCommon: Remove unnecessary includes 2017-02-01 12:19:55 -05:00
Lioncash 273ace7bb7 LightingShaderGen: Remove unnecessary includes 2017-02-01 01:06:00 -05:00
Stenzek 3b218c64b1 Vulkan: Refactor initialization to only use a single instance
Hopefully will fix the crash in vkDestroyInstance on the NV Shield TV,
and likely reduce boot times slightly for drivers that take a while
to create instances.
2017-01-29 22:18:53 +10:00
Lioncash 70cf774a5c RenderBase: Forward declare EFBAccessType 2017-01-23 12:41:26 -05:00
Lioncash 5b461f50af VideoBackendBase: Convert EFBAccessType into an enum class 2017-01-23 03:53:38 -05:00
Florent Castelli e55ec1ed35 cmake: Build D3D and D3D12 video backends 2017-01-21 00:35:55 +01:00
Matthew Parlane ad84b904e4 Merge pull request #4496 from Mystro256/master
Fix GCC build issue with Fedora (linux)
2017-01-13 23:13:08 +13:00
degasus f12460d1f4 VideoSW: Fix GL ES shader. 2017-01-07 12:32:15 +01:00
degasus 23b0faeba5 OGL: Use VideoCommon blend state for framebuffer configuration. 2017-01-06 14:01:39 +01:00
BhaaL 23d99f2f2c specify custom brace style to fix unions
BreakBeforeBraces: Allman apparently includes all styles,
except for AfterUnion (which is false) when using clang-format -dump-config
2017-01-05 12:55:13 +01:00
degasus 41b0c74e30 VideoCommon: Make dst_alpha state implicit. 2017-01-04 20:02:31 +01:00
degasus b7d8bd13a6 OGL/Vulkan: Drop dual pass alpha. 2017-01-04 19:59:41 +01:00
Markus Wick 96314a0ec1 Merge pull request #4574 from stenzek/vulkan-alpha-clear
Vulkan: Clear alpha channel to 0 when pixel format has no alpha channel
2017-01-02 12:29:36 +01:00
Jules Blok ee7a2edf35 Update comments 2016-12-27 21:32:52 +01:00
Jules Blok 65b5765858 VideoBackends: Clamp the range to the maximum depth value supported in the z buffer. 2016-12-27 20:25:40 +01:00
Jules Blok 2ab6711f43 VideoBackends: Use the full depth range when inverted depth range is unsupported. 2016-12-27 14:31:17 +01:00
Jules Blok ef82aebb97 VideoCommon: Don't process the depth range in the vertex shader if it's not oversized. 2016-12-27 14:31:17 +01:00
Stenzek e6249619a0 Vulkan/GL: Set the alpha channel to 0 when creating the EFB framebuffer 2016-12-27 13:06:08 +10:00
Stenzek d1dd910f17 Vulkan: Clear alpha channel to 0 when pixel format has no alpha channel 2016-12-27 12:59:52 +10:00
degasus abf9bb170b TextureCache: Drop unused parameter in backend API. 2016-12-26 22:10:32 +01:00
degasus 04f319066d TextureCache: Extract BP enum check to VideoCommon.
We have TOO many video backends.
2016-12-26 22:10:21 +01:00
Mystro256 1963996dd0 Change RasterFont static const names
Fixes build issue with GCC/CPP 6.2.1 build issues on Fedora 26
2016-12-24 11:58:07 -05:00
Mat M 9160be50db Merge pull request #4224 from lioncash/tcache
TextureCacheBase: Eliminate static state
2016-12-23 04:33:42 -05:00
Markus Wick b5fe0b5b83 Merge pull request #4528 from stenzek/vulkan-descriptor-crash
Vulkan: Fix crash where a potentially deleted buffer is referenced
2016-12-20 11:11:54 +01:00
Stenzek 01047319f8 Merge pull request #4517 from stenzek/mp3-blotches
TextureCache: Use same color coefficients for EFB2Tex as EFB2RAM
2016-12-19 22:11:38 +10:00
Stenzek 9290bf5844 Vulkan: Fix crash where a potentially deleted buffer is referenced
This happened when the geometry shader was disabled, and the uniform
buffer was grown to a larger size. The update would be skipped, leaving
the old buffer to be included in the descriptor set.
2016-12-19 22:00:42 +10:00
Markus Wick 989cdc0929 Merge pull request #4505 from hthh/macos-likes-pbos
OpenGL: Always use a PBO in EncodeToRamUsingShader
2016-12-19 09:47:40 +01:00
Stenzek accce4294a TextureCache: Use same color coefficients for EFB2Tex as EFB2RAM 2016-12-15 02:20:46 +10:00
Stenzek d6cdf49769 VideoSoftware: Don't drop least significant bit of 5-bit blue channels 2016-12-14 23:56:06 +10:00
hthh 801d1d1876 OpenGL: Always use a PBO in EncodeToRamUsingShader
This improves performance significantly on macOS, particularly
noticeably in the Super Mario Sunshine transition, which goes
from ~5FPS to ~17FPS.
2016-12-12 20:33:41 +11:00
Stenzek 607ce40f0b OGL: Fix black screen when MSAA is enabled 2016-12-12 17:51:19 +10:00
Lioncash 58a5395173 TextureCacheBase: Eliminate static state 2016-12-09 16:50:37 -05:00
Stenzek af706efaef Vulkan: Fix viewport depth when depth clamp is unsupported 2016-12-09 22:45:10 +10:00
Léo Lam 31ccfffd38 Common: Add alignment header
Gets rid of duplicated alignment code.
2016-12-06 20:33:53 +01:00
Markus Wick 7192789c11 Merge pull request #4486 from stenzek/gl-minimize-assert
OGL: Fix assertion when minimizing window
2016-12-05 12:46:29 +01:00
Stenzek bff394ec8a Merge pull request #4489 from stenzek/vulkan-minor-fixes
Vulkan: Minor fixes
2016-12-05 12:19:49 +10:00
Stenzek 8f97a24904 Vulkan: Enable GS instancing 2016-12-04 20:53:49 +10:00
Stenzek 9736198c3b Vulkan: Use explicit barriers instead of dependancies
At least on NV, some of these don't seem to have the intended effect. One
known instance of this is in texture conversion.
2016-12-04 20:10:13 +10:00
Stenzek a475792163 Vulkan: Fix incorrect logic in readback preemption
This could have been causing a large number of command buffer
submissions per frame, depending on when the readbacks occured.
2016-12-04 20:10:13 +10:00