summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhid3d11.cpp
Commit message (Collapse)AuthorAgeFilesLines
* rhi: Further reduce copying in the command bufferLaszlo Agocs2020-10-161-71/+45
| | | | | Change-Id: I2e2ff5f4b8aa91d0accb01108a5199b98c371455 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Fix up vertex inputs with matricesLaszlo Agocs2020-10-141-3/+17
| | | | | | | | | | | | In order to prevent too much voodoo in backends like D3D11, the input layout is expected to specify the slice index for vecX that are part of an unrolled matrix. Also deoptimize the instancing manual test to exercise a matrix too instead of just vectors. Change-Id: If2dcbcbc483645ce2420b2f87dda765b95da6e80 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Make the new direct buffer update available for non-uniform buffersLaszlo Agocs2020-10-121-4/+4
| | | | | | | | | | | | | | | | | The original restriction to UniformBuffer was due to the GL backend where there is no GL buffer object for QRhiBuffers with usage UniformBuffer. However, we can still implement this for cases when there is a true GL buffer object underneath. With other backends it should all work as-is already. This becomes useful when one has buffers with usage Vertex that need full updates every frame. (f.ex. instance data) Unfortunately this involves renaming the function. But while at it, add an autotest case as well. Change-Id: Iff59e4509a8bae06654cc92fe8428bd79eb012fb Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: d3d: Save a few cycles in bindShaderResourcesLaszlo Agocs2020-10-111-120/+134
| | | | | Change-Id: Ib11ea33eb695d4599f4f040415d497aaf19cb15b Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: d3d: Calculate dynamic offset usage upfrontLaszlo Agocs2020-10-111-9/+16
| | | | | | | Also remove an unnecessary buffer type test. Change-Id: I6f8312f03d3fe1729fa9b2eb95f6bfbeeccd0d4f Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: gl: d3d: Reduce the size of the Command structLaszlo Agocs2020-10-111-14/+18
| | | | | | | Copied by value so the size matters. Change-Id: I17eae99212801a4fb390a0e298b361123644d17d Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Add support for full, direct buffer updatesLaszlo Agocs2020-10-111-0/+25
| | | | | Change-Id: I02c1f8c32c08d39cde9845d20ba8b02541d9d325 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Make per-frame flags per-pass where appropriateLaszlo Agocs2020-10-021-2/+5
| | | | | | | | | | | | | | | | | | | | ExternalContentsInPass becomes a per-pass flag now. Why is this beneficial? Because while Qt Quick has no choice for its render pass, not being able to guess if the application wants to do some native rendering in there, Quick 3D's render passes, all the ones that are under Quick3D's control, do not have native rendering from the application in them, and so using secondary command buffers with Vulkan is not necessary. Introduce something similar for compute and OpenGL. By knowing that none of the resources used in a pass are used with a compute pass (e.g. because we know that there are no compute passes at all) a small amount of time can be saved by skipping tracking buffers and textures because the only purpose of said tracking is to generate barriers that are relevant only to compute. Change-Id: I0eceb4774d87803c73a39db527f5707a9f4d75c1 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Manage buffer data without QBALaszlo Agocs2020-09-301-4/+4
| | | | | | | | Use a simple and straightforward container that only does what we need here. Change-Id: I1a81b53a58bc91d533e3d7df5471a1362046825d Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Improve layout compatibility test performanceLaszlo Agocs2020-09-291-0/+2
| | | | | | | | | Also bump the non-heap buffer size in the binding list to 16, in order to accommodate complex Quick3D materials with many associated texture maps. Change-Id: Id190e5f8304f5941cffc41a2605fce45dfeb72f0 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: gl: d3d: Do not use QByteArray where there is no pointLaszlo Agocs2020-09-251-7/+8
| | | | | | | | | The real benefit in practice is getting rid of profilers going wild about QByteArray::begin() and similar. The actual perf. gain is fairly small. Change-Id: I25e4c762f303b41f0aaf914bc62751f3265d3cf8 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* rhi: Reuse the data in buffer ops in res.update batchesLaszlo Agocs2020-09-231-3/+3
| | | | | | | | Because having profilers bombarded with mallocs (due to creating deep copy QByteArrays) is not nice. Change-Id: I848f41f3465d6dc2a58a193cc863495aacf13d79 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Reuse buffer/texture op entries in res.update batchesLaszlo Agocs2020-09-231-3/+4
| | | | | | | | More of an enabler for reusing the data in the individual entries since not clearing the QVLA does not give us much on its own. Change-Id: Ief9761f75382c3373cc2bc7b866eb59fdd8b3277 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: d3d: Fix dynamic offsets with multiple buffersLaszlo Agocs2020-09-231-14/+33
| | | | | | Fixes: QTBUG-86821 Change-Id: I57f86bf0f7e95b92f5b2c5fee587112ecf0fc8e6 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Support signed integer attributes on QRHIInho Lee2020-09-211-1/+9
| | | | | | | Previous UIntAttributes feature is renamed as IntAttributes. Change-Id: I4b4a87a0eebf37291da832605f7bee8fb2d4e62b Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: Expose compute threadgroup limits in ResourceLimitsLaszlo Agocs2020-09-181-0/+10
| | | | | | | | | | As OpenGL ES and Vulkan ruin the day with the spec mandated minimum value for max threads per threadgroup being only 128, clients need a way to decide if their compute shader (local_size_*) is suitable for use at run time. Change-Id: I72b4fc97032406340623add82ea4d9544ebe9fdc Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Sanity check the srb in debug buildsLaszlo Agocs2020-09-031-0/+4
| | | | | | | | | | | Instead of cryptic assertions and crashes depending on the backend, show some useful warnings (in debug builds only) when one tries to create an srb with a list where there are duplicated bindings. (a mistake that happens relatively often during the development of frameworks, such as Quick 3D, on top) Change-Id: If1b50a2e8165b001878ad566e048f146e636514f Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: d3d: Allow compiling source shaders with debug at run timeLaszlo Agocs2020-08-281-4/+15
| | | | | | | | | | Relevant for Qt Quick 3D. As in many cases Quick3D will rely on runtime generated shader code, the translated HLSL will be compiled via D3DCompile() at run time. To make such shaders debuggable, the necessary flag (D3DCOMPILE_DEBUG) should be requestable somehow. Change-Id: I4d5c3b57bf58df8d46556eebb5cf6fb75e9d0afe Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: d3d11: Enable setting xxxColor as an alpha src/dst blend factorLaszlo Agocs2020-08-191-11/+17
| | | | | | | Fixes: QTBUG-86111 Pick-to: 5.15 Change-Id: Iabcf1708ea65e9f05f39caf9df9b45c25ac5dbb8 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Use QList instead of QVector in gui implementationJarek Kobus2020-07-071-1/+1
| | | | | | | Task-number: QTBUG-84469 Change-Id: I366e845249203d80d640355a7780ac2f91a762f1 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* rhi: add support for D24 / D24S8 formatsJean-Michaël Celerier2020-07-021-0/+14
| | | | | Change-Id: I7ba14d30fa57bcb92cd764aed6c85cde853935b4 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Switch to qvla where it makes sense in rhiLaszlo Agocs2020-06-301-2/+2
| | | | | | | | | For all of these we know in advance that the vast majority of usages will not exceed a certain number of elements. Also, none of these are copied or moved ever. Change-Id: I48aedf143e221dc178d661e23454d1e4fb7a271b Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Enable specifying just an adapter or phys devLaszlo Agocs2020-06-261-17/+65
| | | | | | | | | Required by OpenXR. A VkPhysicalDevice or an adapter LUID + feature level pair should be adoptable while leaving the rest (device, queue, etc. setup) to QRhi as normal. Change-Id: Iada0972671b037b4efb03e7831b7c9b8c5f2393d Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Add a feature flag for readback format supportLaszlo Agocs2020-06-151-0/+2
| | | | | | | | | Indicate that doing a QRhiResourceUpdateBatch::readBackTexture() for texture formats other than RGBA/BGRA is not necessarily supported at run time. Change-Id: Ie9ca9546a3af9bff142b875f1ecf26bf26bcc442 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Add RHI feature check for screen space derivativesEskil Abrahamsen Blomfeldt2020-06-121-0/+2
| | | | | | | | | | | | | | Fragment shader functions like fwidth() are useful for antialiasing distance field text in the case of perspective projections. In order to enable this as an alternative code path, we need to detect support. - OpenGL: Supported with GL_OES_standard_derivatives or GLES3 and up - Direct 3D: Supported for ps_2_x, so always supported on Direct3D 11 - Vulkan/Metal: Always supported Task-number: QTBUG-84695 Change-Id: I5e3fa8014c808a9a2d639305c5e90ec25d44655c Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Remove winrtOliver Wolff2020-06-061-4/+0
| | | | | | | | | Macros and the await helper function from qfunctions_winrt(_p).h are needed in other Qt modules which use UWP APIs on desktop windows. Task-number: QTBUG-84434 Change-Id: Ice09c11436ad151c17bdccd2c7defadd08c13925 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* rhi: Harmonize create-destroy API pattern with the rest of QtLaszlo Agocs2020-05-281-51/+51
| | | | | | | | | | For historical reasons we use build and release instead of create and destroy. This becomes confusing now that more modules in Qt start taking QRhi into use. Migrate to the more familiar naming, so those who have used QWindow or QOpenGLContext before will find it natural. Change-Id: I05eb2243ce274c59b03a5f8bcbb2792a4f37120f Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* rhi: d3d11: Use qstrncpy to avoid MSVC warningLaszlo Agocs2020-05-281-4/+2
| | | | | | | | | | | | | Switch strncpy to qstrncpy, which internally uses strncpy_s with MSVC. This way we will not get the following warning: qrhid3d11.cpp(933): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. Change-Id: Iaed86033b0fc182e68804f311ac382c93c72abda Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* QRhiVertexInputAttribute : Add unsigned int formats for vertex inputInho Lee2020-05-271-0/+10
| | | | | | Task-number: QTBUG-83173 Change-Id: I640cd1fe74227d2cc96672d6c7aaac93e1930bcd Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* RHI: Introduce QRhiTexture::RG8VaL Doroshchuk2020-05-251-0/+4
| | | | | | Change-Id: I58f35b2629bd6464f08cba66e852215472fcbe2a Fixes: QTBUG-84384 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* RHI: Store texture handle as 64-bit intEskil Abrahamsen Blomfeldt2020-05-221-4/+4
| | | | | | | | | | | | | | | | | | When storing a void* pointer to the texture handle, we had to ensure that the variable would exist until the build phase, which is error prone and caused errors in QQuickWidget because we copied the texture ID from the FBO into a local variable before passing it into QQuickWindow::setRenderTarget(). The reason for using a void* was that we cannot know the width of the handles in the different backends, but we do know that they are 64-bit at maximum, so instead of storing potentially dangling pointers, we just make it a 64-bit integer and cast it back and forth in the backends. Task-number: QTBUG-78638 Change-Id: I7951e24351ddb209045ab6197d81eb1290b4da67 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: d3d11: Handle DXGI_ERROR_SDK_COMPONENT_MISSING gracefullyLaszlo Agocs2020-05-121-0/+9
| | | | | | | | | | | | Requesting the debug layer is not something that succeeds at run time if the corresponding SDK component is not present. Handle it gracefully: simply retry D3D11CreateDevice without the debug device flag. Relevant also for the Qt CI's Windows 10 VMs. Task-number: QTBUG-84067 Change-Id: Ia7b2562917ec11ce04a75c052527bf526d1fe81b Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Warn better in D3D/Vulkan for incompatible multisample resolve formatsLaszlo Agocs2020-04-301-2/+4
| | | | | | | | | | | | | | | Attempting to resolve a multisample image into a non-multisample one is only valid when the formats are the same, as per Vulkan spec and D3D docs. With Vulkan, this is sometimes not fatal, some implementations can apparently deal with some format combinations, so the problem may not be trivial to catch, although with validation layer enabled a warning is shown at least. To make it easier to discover, have our own warning. Task-number: QTBUG-83707 Change-Id: I8fc87471de91cd65a445fbe8cedbf31a8295db53 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* rhi: Add backing format hint to QRhiRenderBufferLaszlo Agocs2020-04-291-6/+12
| | | | | | Task-number: QTBUG-83707 Change-Id: I63548f4ace70af614a2aa082663bb3ae9fbedc25 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* rhi: Take mip size into account for render target sizeLaszlo Agocs2020-04-231-1/+3
| | | | | | | | Also extend autotesting, both for rendering into a given mip level and for rendering into a given cubemap face. Change-Id: Ida94b71150477ceb50a3b5616d8b7be13174558b Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: d3d11: Disable DXGI message queue monitoringLaszlo Agocs2020-04-061-1/+1
| | | | | | | | | | We do not benefit from it (don't need Alt+Enter and such). Switching to DXGI_MWA_NO_WINDOW_CHANGES is also in line with the qtbase/5.14 patch 1430b29 that does the same for ANGLE. Change-Id: Ie6384aeb2e97130ff439f761a7c166086f04526c Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* rhi: d3d11: Honor resource/sampler slot limitsLaszlo Agocs2020-03-101-66/+124
| | | | | | | | | | | | | | Show a warning but allow applications to survive by not attempting to call VS/PS/CSSetWhatever() with an invalid number of resources. Relevant for samplers in particular, where the limit is 16. Qt Quick 3D exhibits problems with this when using custom materials combined with shadow mapping, and while this is not a solution to the problem there, at least the problem is now clearly indicated instead of crashing. Task-number: QTBUG-82719 Change-Id: I83914b7648001fa421ed1cf07a7b7444e0ef8fc0 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Add support for arrays of combined image samplersLaszlo Agocs2020-03-051-37/+55
| | | | | | | | | | | | | | | | Introduces a new QRhiShaderResourceBinding function that takes an array of texture-sampler pairs. The existing function is also available and is equivalent to calling the array-based version with array size 1. It is important to note that for Metal one needs MSL 2.0 for array of textures, so qsb needs --msl 20 instead of --msl 12 for such shaders. Comes with an autotest, and also updates all .qsb files for said test with the latest shadertools. Task-number: QTBUG-82624 Change-Id: Ibc1973aae826836f16d842c41d6c8403fd7ff876 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: d3d: Use native resource binding mapping table when presentLaszlo Agocs2020-03-031-59/+198
| | | | | | | | | | | | | | | | Newer versions of QShaderBaker will now use distinct, zero-based b, t+s, and u register spaces in the generated HLSL source. If this is the case, the native resource binding map (which so far we only used with Metal) contains the SPIR-V binding -> HLSL register binding mappings. This way we won't end up with invalid resource binding attempts (consider that e.g. D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT is only 16), just because, for example, a combined image sampler had a binding of 18 which then got blindly mapped to s18 and t18 in HLSL. Task-number: QTBUG-82472 Change-Id: I8bdcb5378634cf159f6367424582f9e9e5821c8e Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Execute pending host writes on nativeBuffer() queryLaszlo Agocs2020-03-031-4/+8
| | | | | | | | | | | | | Otherwise it is impossible to write an application that pulls out the VkBuffer for a Dynamic QRhiBuffer, and then uses it with custom Vulkan operations that read from the buffer. More precisely, the problem arises only if the buffer in question is not used in combination with any QRhi operations, because in that case there is nothing that would trigger doing the host writes queued up by a resource batch's updateDynamicBuffer(). Task-number: QTBUG-82435 Change-Id: Ieb54422f1493921bc6d4d029be56130cd3a1362a Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Allow querying the native buffer objects behind a QRhiBufferLaszlo Agocs2020-02-211-0/+5
| | | | | | | | | | | | | Modeled after QRhiTexture's NativeTexture query. This becomes valuable in advanced cases of integrating external native rendering code with Qt Quick(3D), because it allows using (typically vertex and index) buffers created by Quick(3D) in the custom renderer as well, without having to duplicate the content by manually creating native buffers with the same vertex and index data. Change-Id: I659193345fa1dfe6221b898043f0b75ba649d296 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Do not rely on unspecified relation between readbacks and FramesInFlightLaszlo Agocs2020-02-211-1/+7
| | | | | | | | | | | | | | | Add a new queriable resource limit value MaxAsyncReadbackFrames. Change the autotest to rely on this instead of relying on the unspecified, works-by-accident relation between readbacks and FramesInFlight. This way even if the behavior diverges in some backend in the future, clients (well written ones, that is), will continue to function correctly. Also clarify the docs for FramesInFlight, and change d3d and gl to return the correct value (which is 1 from QRhi perspective; the expanded docs now explain a bit what this really means and what it does not). Change-Id: I0486715570a9e6fc5d3dc431694d1712875dfe01 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Allow detecting texelFetch supportLaszlo Agocs2020-02-131-0/+2
| | | | | Change-Id: I166c89af99e1289ae60febf2f41fab07eab9f7e8 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* rhi: Add depth bias and slope scaled depth biasLaszlo Agocs2020-02-061-0/+2
| | | | | | | | | Beware of the API terminology: GL 'factor' = 'slope scaled depth bias', GL 'units' = '(constant) depth bias'. Task-number: QTBUG-81843 Change-Id: I03e3618d007cbf7100add0de4950a6163d788cc7 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* rhi: d3d: Make DepthClipEnable set to trueLaszlo Agocs2020-02-061-0/+1
| | | | | | | | ...which is the natural default, and matches other backends. Task-number: QTBUG-81852 Change-Id: I6d0788b18eb7601661ef646e650114a503a12215 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* rhi: Enable sampler address mode W in the APILaszlo Agocs2020-01-301-4/+4
| | | | | | | | | | | Internally this is already supported by all backends. The frontend was just not exposing addressW, instead defaulting to the (arbitrarily chosen) ClampToEdge. Add the parameter to newSampler(), but make it optional, defaulting to the more natural Repeat (because that's what one would get with OpenGL for WRAP_R by default) Change-Id: I0b991d8b649db37d4da86ac8e98ab7845601cf67 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Add R16F and R32FLaszlo Agocs2020-01-091-0/+4
| | | | | | | | Can be relevant for Qt Quick 3D shadows, where the shadow map is R16F. Task-number: QTBUG-81268 Change-Id: Ic33e100929e133d1cbe0b062a15697c82536f62a Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* rhi: Remove ugly fallthroughsLaszlo Agocs2020-01-091-26/+0
| | | | | | | The coding style does not actually require this. Change-Id: I2be7cd29c4dabfed2822cd7fb63e597c071e5e15 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* RHI: Remove old native texture APIPaul Olav Tvete2020-01-061-42/+1
| | | | | | Task-number: QTBUG-78570 Change-Id: I8c4850828ac03319ac923a26c2e985883956c286 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* RHI: new native texture APIPaul Olav Tvete2019-12-051-0/+28
| | | | | | | | | | | | The new version takes/returns a value that can be unpacked and passed to other functions without knowing which backend is in use. The old API will be removed in a later change when dependent modules have been updated Task-number: QTBUG-78570 Change-Id: I18d928ceef3cb617c0c509ecccb345551a7990af Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>