Commit Graph

129828 Commits

Author SHA1 Message Date
Alejandro Piñeiro 8f46750f46 v3dv/device: get proper device ID under simulator
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:32 +00:00
Alejandro Piñeiro ffaab5593c v3dv/device: add vendorID/deviceID get helpers
As we would need them for the pipeline cache header.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:32 +00:00
Iago Toral Quiroga a2723154c5 v3dv: fix dynamic state after meta operation
We should always save state on a push before starting a meta operation,
even if we don't have a pipeline, since dynamic state can be set at any
time directly on the command buffer. Similarly, we should always restore
it if the pop after the meta operation signals that it has written any
state, not only if we have a graphics pipeline to restore.

Fixes a rendering artifact in VkQuake.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:32 +00:00
Iago Toral Quiroga 33a6fdb53d v3dv: enable fillModeNonSolid
This, together with the shaderClipDistance changes, gets vkQuake3
to run without hacks.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:32 +00:00
Iago Toral Quiroga 558987a465 v3dv: enable shaderClipDistance
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:32 +00:00
Iago Toral Quiroga 47e02a2ef1 v3dv: add a fast path for vkCmdClearAttachments
Since vkCmdClearAttachments executes inside a render pass, we would
benefit from converting it to a draw within the current subpass job to
improve batching and avoid expensive tile load/store operations.

This can dramatically improve performance for applications using this
command, however, we can only use this if we are clearing the base
layers of framebuffer attachments, since otherwise we would need to
use layered rendering, which we don't support yet.

This improves vkQuake3 performance dramatically (almost 100%
performance improvement at 1080p), which calls this twice per frame.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:32 +00:00
Iago Toral Quiroga c5d07802dc v3dv: only clear depth/stencil attachments if any aspect needs clearing
When we can't perform the clears using the TLB and fallback to
vkCmdClearAttachments make sure we only emit the clear if any of
the depth/stencil aspects actually needs it.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:32 +00:00
Iago Toral Quiroga c4564f62aa v3dv: emit new shader state if viewport is dirty
If we have a dirty viewport then we need to re-emit our uniforms
to update QUNIFORM_VIEWPORT_*.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:32 +00:00
Iago Toral Quiroga e7678f7c7f v3dv: only care about barriers between GPU jobs
We don't need to do anything special for host/gpu synchronization.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:32 +00:00
Iago Toral Quiroga 08193cc56f v3dv: avoid prime blit path when presenting WSI images
This allows us to present WSI images directly rather than going through
a blit path, improving performance.

This improves vkQuake performance at 1080p by 10-20%.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:32 +00:00
Iago Toral Quiroga 97891898c3 v3dv: only use per-buffer clear bit for cases were we are already storing
This bit is helpful if we already need to store the buffer, but otherwise
we should not emit the store only to get the clear, we can use the global
clear packet for that and save us an expensive tile buffer store operation.

Also, we have not been using the per-buffer clear bit for depth/stencil
stores since "v3dv: fix depth/stencil clears on hardware", so we should
never been considering clearing needs to flag stores.

This improves vkQuake performance somewhere between 5%-15% by allowing
us to skip the store of the depth attachment.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:32 +00:00
Iago Toral Quiroga add8778638 v3dv: ignore stencil load operation if attachment format doesn't have stencil
This gets vkQuake to render correctly, which creates render passes with
stencil load operations even when the depth/stencil attachment format
doesn't have a stencil aspect. While this is a bit weird, it seems to
be allowed by the spec:

   "If the format has depth and/or stencil components, loadOp and storeOp
    apply only to the depth data, while stencilLoadOp and stencilStoreOp
    define how the stencil data is handled."

In our case we were not ignoring it and this was causing that we emitted a
Z buffer load that seemed to clobber the Z clear, preventing all draw calls
from passing the depth test.

While we are at it, also change the depth/stencil store operation (which
was already handling this scenario correctly) to use the format of the
render pass attachment description rather than the underlying image
format.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:32 +00:00
Iago Toral Quiroga 1e1903fc1b v3dv: use a binning sync for CL jobs waiting on a semaphore
If we have a semaphore wait the job cannot be started before the semaphore
has been signaled, so we need to wait before starting the binning stage.

Fixes CTS failures in:
dEQP-VK.synchronization.op.single_queue.binary_semaphore.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:32 +00:00
Iago Toral Quiroga 0db95de577 v3dv: improve pipeline barrier handling
So far we have been getting away with finishing the current job in the
presence of a pipeline barrier and relying on the RCL serialization,
but of course this is not always enough.

This patch  addresses synchronization across different GPU units
(i.e. draw indirect after compute), as well as cases where we need to
sync before binning.

Fixes CTS failures in:
dEQP-VK.synchronization.op.single_queue.barrier.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga adbce7723e v3dv: don't support sRGB buffer formats
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga d08da4a54a v3dv: handle VK_FORMAT_B8G8R8A8_UNORM vertex attributes
This is the only mandatory vertex attribute format that requires a
swizzle.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga 5a2ef59963 v3d/compiler: support swapping R/B channels in vertex attributes.
We will need this in Vulkan to support vertex format
VK_FORMAT_B8G8R8A8_UNORM.  The hardware doesn't allow to swizzle
vertex attribute components, so we need to do it in the shader.

v2:
 - Use nir_intrinsic_io_semantics() to retrieve the location instead
   of looping through the shader input variables (Eric).
 - Assert that we only have one component (Eric).

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> (v1)
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga a2538b2520 v3dv: make sure we emit vertex attributes in location order
The order in which we emit the attributes is relevant, since
GL_SHADER_STATE_ATTRIBUTE_RECORD packets don't include an explicit
attribute index. This means that we need to emit them in driver
location order, since the compiler uses that location to compute
attribute offsets in the VPM.

Fixes ~1300 CTS tests in:
dEQP-VK.pipeline.vertex_input.multiple_attributes.out_of_order.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
n00b7 aebfdfa04c v3dv/device: handle primary nodes for newer kernels
For kernels rpi-5.X.y it changed from brcm,bcm2835-vc4 to
brcm,bcm2711-vc5, so let's just check for both strings.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga 3bd02a729a v3dv: fix color border clamping with specific formats
For some reason, CTS expects E5B9G9R9 and B10G11R11 with
transparent black border clamping produce alpha 1 instead of 0.

Since border color takes precedence over the texture state swizzle,
the only way to fix this is to lower the texture swizzle in the shader
to set alpha to 1.

Fixes:
dEQP-VK.pipeline.sampler.view_type.*b10g11r11*clamp_to_border_transparent_black
dEQP-VK.pipeline.sampler.view_type.*e5b9g9r9*.clamp_to_border_transparent_black

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga f156c5dc4d v3dv: fix regressions for cubemap array load/store
It seems that we only want to set the texture state's depth to the
number of 2D layers divided by 6 when sampling, not wen doing
load/store.

This means that we need to generate two different states and choose
the one to use depending on the descriptor.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga 9eb1b578ee v3dv: use swizzle X001 with D/S formats
This matches Vulkan CTS expectations.

Fixes (for D/S formats):
dEQP-VK.pipeline.sampler.view_type.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Alejandro Piñeiro 336d9e187c v3dv/image: fix TEXTURE_SHADER_STATE depth for cube arrays
For these we want to divide the number of layers by 6.

Fixes:
dEQP-VK.pipeline.image_view.view_type.cube_array.*
dEQP-VK.pipeline.image.suballocation.sampling_type.combined.view_type.cube_array.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga cb1e492ee0 v3dv: handle unnormalized coordinates in samplers
In OpenGL, unnormalized coordinates are implicit based on the sampler
type (rectangle textures), so the compiler can set the flag when needed.
In Vulkan, however, this is configured explicitly in the sampler object,
so the compiler won't set it and we need to do it manually when we are
writing the P1 uniform.

Fixes:
dEQP-VK.pipeline.sampler.exact_sampling.*.unnormalized_coords

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga 0385da9e08 v3dv: fix blit_shader() to honor the region's aspect mask
When translating combined depth/stencil blits to compatible color blits we
should look at the requested region aspects to decide the color
mask to apply.

Fixes:
dEQP-VK.api.copy_and_blit.*.buffer_to_depthstencil.buffer_offset_d24_unorm_s8_uint_D
dEQP-VK.api.copy_and_blit.*.buffer_to_depthstencil.buffer_offset_d24_unorm_s8_uint_SD
dEQP-VK.api.copy_and_blit.*.buffer_to_depthstencil.buffer_offset_d24_unorm_s8_uint_S_D

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga bf20a5e7b7 v3dv: fix srcSubresource description for image to buffer blits
We are emitting a loop copying layer by layer here.

Fixes:
dEQP-VK.pipeline.render_to_image.core.*.huge.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga 6053e85ee4 v3dv: fix textureSize() for cube arrays
For these we want to divide the number of layers by 6.

Fixes:
dEQP-VK.glsl.texture_functions.query.texturesize.*samplercubearray*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga b6c2fde4b9 v3dv: fix vkCmdCopyBuffer unaligned TLB access
We need to make sure that our tile load/store operations are aligned
to the selected item size for the copy.

Fixes simulator assert in VkQuake.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga 56fcc085fb v3dv: handle draw after barrier
Currently, we end the current job whenever the user emits a
pipeline barrier, but we then expect to have a valid job when
we emit a draw call.

If by the time we have to emit a draw call we don't have a valid
job, we need to create one by resuming execution of the current
subpass.

Fixes some tests in:
dEQP-VK.renderpass.suballocation.attachment_allocation.input_output.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga 8116d65fbc v3dv: improve handling of too large image sizes
Instead of asserting that users don't try to create images that
would require 4GB+ of memory, error out with the corresponding
OOM error when the user tries to actually allocate the memory
for the image.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga b546155cc3 v3dv: add workaround for GFXH-1602
The first attribute must be active if using builtins.

This fixes a lot of simulator crashes for vertex input CTS tests.
It should be noted that some of these tests still fail after this
fix though, so there may be some other bug.

Fixes crashes in:
dEQP-VK.pipeline.vertex_input.multiple_attributes.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga f6e7290cbc v3dv: fix GFXH-930 workaround
We want to check if the coordinate shader is reading attributes, not
the vertex shader.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Alejandro Piñeiro e01d6af98e v3dv/device: expose support for image cube array
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Alejandro Piñeiro 10b79bf901 nir: include texture query lod as one of the ops that requires a sampler
In practice we found that we need this for v3d (specifically for cube
map arrays, as they don't support the default value for wrap_i, so a
sampler object is needed to override that value).

It is worth to note that the main reason behind this auxiliar method
was to identify those cases that we didn't have a sampler object
available for Vulkan. So far, we found that we have a sampler object
coming from nir always for that operation.

Fixes cube map array tests like the following:
dEQP-VK.glsl.texture_functions.query.texturequerylod.usamplercubearray_fragment

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Alejandro Piñeiro b6ccdd59cd v3dv/uniforms: support for some QUNIFORM_IMAGE_XXX
As we are using the descriptor sets to access to the specific
v3dv_image_view, we can just reuse the existing methods for the
textures.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Alejandro Piñeiro 42b1cacbc6 v3dv/pipeline: lower_image_deref
This is really similar to the existing lower_tex_src_to_offset, but
for now we prefer to keep them independent, just in case we start to
found specific image use-cases as we advance fixing CTS tests.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Alejandro Piñeiro 407411036c v3dv/descriptors: support for DESCRIPTOR_TYPE_STORAGE_IMAGE
From the descriptor pov is mostly another image without sampler, so
for example, on the descriptor pool bo we only store the texture
shader state.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga 91907560d5 v3dv: implement support for shader spilling
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga 182e7c2d96 v3dv: lower frexp
Fixes:
dEQP-VK.glsl.builtin.precision.frexp.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga 4b86903313 v3dv: lower unpack_{u,s}norm_2x16
The hardware doesn't have unorm/snorm packing variants and we were
already lowering the packing versions of these.

Fixes:
dEQP-VK.glsl.builtin.function.pack_unpack.unpacksnorm2x16_compute
dEQP-VK.glsl.builtin.function.pack_unpack.unpackunorm2x16_compute

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga e59e706928 v3dv: don't reset descriptor state after a meta operation
If the meta operation did not change descriptor state then we should keep it,
not reset it.

Fixes:
dEQP-VK.fragment_operations.early_fragment.early_fragment_tests_stencil
dEQP-VK.fragment_operations.early_fragment.no_early_fragment_tests_stencil

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga 4b9e3bbf48 v3dv: handle empty set layouts
Fixes:
dEQP-VK.api.object_management.max_concurrent.descriptor_set_layout_empty
dEQP-VK.api.object_management.single_alloc_callbacks.descriptor_set_layout_empty

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Alejandro Piñeiro 9833a5ae70 v3dv: initial support for input attachments
We are treating them as a special case of texture, so the commit is
mostly about integrating them with the existing
SAMPLER/SAMPLER_IMAGE/COMBINED_IMAGE_SAMPLER infrastructure.

This commit doesn't use in any special way the render pass
information, including the dependencies, so it is possible that we
would need to do something else. But this commit gets several CTS
tests, and two Sascha Willem Vulkan demos, so let's start with this
commit and handle any other use case for following commits.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Alejandro Piñeiro 19d3639ee7 v3dv/pipeline: set load_layer_id to zero
We don't support layered rendering so let's lower the intrinsic to
zero for now. Based on turnip commit 99a4f7c ("turnip: set
load_layer_id to zero")

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Alejandro Piñeiro 6e0cec5a13 v3dv/pipeline: iterate used textures using the combined index map
So far we were using nir->data.num_textures to fill the default values
for the textures used on the shader, and set the value for the number
of textures used.

But nir->data.num_textures doesn't take into account input
attachments, even after nir_lower_input_attachments. Although that
could make sense from a general pov, in our case we are treating input
attachments mostly as textures.

This commit count the number of textures interating through the
pipeline combined index map, as it includes both. This also makes the
populate of the shader key for default values more similar to the one
done at cmd_buffer with real values.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Alejandro Piñeiro b9dd7e30a6 v3d/tex: avoid to ask back for a sampler state if not needed
So far we were not asking the driver for the sampler state if we could
just use the default P1 values. But even if we need to fill P1 (for
example to fill up the output type of the format), if the texture
operation doesn't need a sampler, we can let that field as NULL (so
default values) and avoid calling back the driver for a sampler.

This is not mandatory for OpenGL (as we always have a sampler object),
although still a good to have. For Vulkan this is needed, as we don't
have a sampler object in that case.

v2: reword comment (Eric)

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga 0dbf040863 v3dv: pipeline initialization fixes for disabled rasterization
When rasterization is disabled there are a number of CreateInfo
structs that should be ignored. We were managing this correctly
for some cases, but not all of them. Specifically, viewport state
must be ignored and we weren't doing that.

Fixes:
dEQP-VK.api.descriptor_set.descriptor_set_layout_lifetime.graphics

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga d809d9f3f6 v3dv: don't free BOs from imported memory objects
Only free the underlying BO when the exported memory object is freed
to avoid multiple frees of the same memory.

The only exception is winsys BOs where we import a BO created in the
display device into the render device. In this case, we only have one
memory object referencing the BO and we want to destroy it with that
memory object.

Fixes:
dEQP-VK.api.external.memory.dma_buf.*
dEQP-VK.api.external.memory.opaque_fd.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga ddb352b8f9 v3dv: assert that our framebuffers are single sampled
This makes it easier to track CTS test fails related to multisampling,
which we don't support yet.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00
Iago Toral Quiroga 95caf46602 v3dv: return a proper error for too large buffer allocations
Fixes: dEQP-VK.api.buffer.basic.size_max_uint64
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:31 +00:00