platform/upstream/mesa.git
4 years agov3dv/pipeline: add support for shader variants
Alejandro Piñeiro [Tue, 24 Mar 2020 11:18:10 +0000 (12:18 +0100)]
v3dv/pipeline: add support for shader variants

So far, we were doing the compilation to qpu when the pipeline was
created (as part of vkCreateGraphicsPipeline).

But this would not be correct when some specific descriptors are
involved, like textures. For that case some nir lowerings depend on
the texture format, and that info is not available until the specific
descriptors are bound to the command buffer. In the same way, the same
command buffer with a given pipeline could get their descriptor bound
again.

So it would be needed to support compilation variants of the same
shader. So finally, the v3d_key would work as keys, as the variants
would be tracked with a hash table.

This commit introduces the new structures for that. What we were
building as the final qpu shader would become the initial default
variant for the pipeline. We are also saving the keys used at that
point, to avoid needing to fully regenerate them when a new variant is
created. Not just for performance, but also to avoid needing to track
the graphics pipeline create info structure.

The code to handle updating the current variant would be done on
following commits.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv/uniforms: filling up QUNIFORM_TMU_CONFIG_P0/P1
Alejandro Piñeiro [Sun, 29 Mar 2020 14:31:17 +0000 (16:31 +0200)]
v3dv/uniforms: filling up QUNIFORM_TMU_CONFIG_P0/P1

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv/descriptor_set: added support for samplers
Alejandro Piñeiro [Sun, 29 Mar 2020 14:29:55 +0000 (16:29 +0200)]
v3dv/descriptor_set: added support for samplers

This include SAMPLER, COMBINED_IMAGE_SAMPLER and SAMPLED_IMAGE
descriptors.

In order to support them we do the pre-packing of TEXTURE_SHADER_STATE
and SAMPLER_STATE when Images and Samplers (respectively) are
created. Those packets doesn't need to be tweaked later, so we upload
them to an bo.

A possible improvement of this would be that the descriptor pool
manages a bo for all descriptors, that suballocate for each descriptor
allocated. This is what other drivers do (and as far as I understand,
one of the reasons of having a descriptor pool).

Immutable samplers are not supported, will be handled on a following
patch.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv/pipeline: sampler lowering
Alejandro Piñeiro [Tue, 10 Mar 2020 11:34:00 +0000 (12:34 +0100)]
v3dv/pipeline: sampler lowering

Add a pass to lower "uniform sampler2d" and others to their
texture/sampler idx.

This commit basically imports the same lowering from turnip.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv/pipeline: unify local allocator name
Alejandro Piñeiro [Tue, 24 Mar 2020 22:08:57 +0000 (23:08 +0100)]
v3dv/pipeline: unify local allocator name

Sometimes called alloc some other pAllocator. Choosing the later for
consistency.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv/uniforms: cleaning up, moving udpate ubo/ssbo uniforms to a function
Alejandro Piñeiro [Mon, 16 Mar 2020 11:59:31 +0000 (12:59 +0100)]
v3dv/uniforms: cleaning up, moving udpate ubo/ssbo uniforms to a function

The code to handle ubo/ssbo has become too big, and made the switch
hard to read. Moved to their own function.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv/cmd_buffer: push constants not using descriptor anymore
Alejandro Piñeiro [Mon, 16 Mar 2020 11:34:02 +0000 (12:34 +0100)]
v3dv/cmd_buffer: push constants not using descriptor anymore

v3dv_descriptor is going to be expanded with more data, so it doesn't
make sense anymore to handle a fake descriptor for the push
constants. Introducing a new struct, that is just a pair
bo/offset. Initially named v3dv_resource, as it could be the base to
reuse bos for different resources (like assembly bo)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: fix a1r5g5b5 format
Iago Toral Quiroga [Wed, 25 Mar 2020 13:17:57 +0000 (14:17 +0100)]
v3dv: fix a1r5g5b5 format

We were configuring the TLB to use ABGR1555, but that doesn't really
give us what we want. There were two issues:

  * We were using the wrong Texture Data Format and Output Image
    Format. In fact those we need to use were not included on the
    packet file.

  * Even using the correct one, we need to do a RB swap to match the
    semantics of the Vulkan format.

This patch fixes both issues. As we are here we keep the formats we
were already used, that would provide support for r5g5b5a1.

So this patch makes tests like the following going from skip to pass:
dEQP-VK.texture.filtering.2d.formats.r5g5b5a1_unorm.nearest

And the following test from fail to pass:
dEQP-VK.texture.filtering.2d.formats.a1r5g5b5_unorm.nearest

Note that the R5G5B5A1_UNORM_PACK16 is not mandatory, but as we
already made the effort to understand them and get them working let's
just keep it on the list

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: don't emit the subpass RCL for jobs that have emitted their own
Iago Toral Quiroga [Wed, 25 Mar 2020 11:09:12 +0000 (12:09 +0100)]
v3dv: don't emit the subpass RCL for jobs that have emitted their own

This fixes multi-layer vkCmdClearAttachments CTS tests. The underlying
problem here is that even though this command runs inside a render pass,
it is implemented as a separate job that emits its own RCL to program
render target color clears, so we should not emit the subpass RCL for it.

Fixes 250+ CTS tests (all but a1r5g5b5) in:
dEQP-VK.api.image_clearing.core.clear_color_attachment.cube_layers.*
dEQP-VK.api.image_clearing.core.clear_color_attachment.multiple_layers.*
dEQP-VK.api.image_clearing.core.clear_depth_stencil_attachment.multiple_layers.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: fix job subpass index for vkCmdClearAttachments jobs
Iago Toral Quiroga [Wed, 25 Mar 2020 11:19:11 +0000 (12:19 +0100)]
v3dv: fix job subpass index for vkCmdClearAttachments jobs

We had changed the interface for job starts so they take the subpass index
rather than a boolean indicating whether the job starts a new subpas, but we
forgot to update this accordingly.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: fix clearing of 3D images
Iago Toral Quiroga [Wed, 25 Mar 2020 07:57:12 +0000 (08:57 +0100)]
v3dv: fix clearing of 3D images

We were not considering that the depth of the image is minified according
to its miplevel. For some reason this only seemed to show up for tiled
images.

Fixes (except a1r5g5b5 format):
dEQP-VK.api.image_clearing.core.clear_color_image.3d.optimal.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: fix incorrect image slice selection
Iago Toral Quiroga [Wed, 25 Mar 2020 07:23:45 +0000 (08:23 +0100)]
v3dv: fix incorrect image slice selection

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: use compatible TLB formats if possible during copies and clears
Iago Toral Quiroga [Tue, 24 Mar 2020 13:04:56 +0000 (14:04 +0100)]
v3dv: use compatible TLB formats if possible during copies and clears

If a format is not supported by the TLB, we can still use the TLB path
if we setup the render target using a compatible format. The only caveat
is that for clears we need to pack the clear value using the original
format of the underlying image, not the compatible format.

With this change we get to use the TLB path successfully for all supported
image formats (except a1r5g5b5, at least for now) so long as the region starts
at (0,0), and we only need to consider fallback paths for partial copies
and clears, not because of the format.

This gets us to pass a few extra hundreds of tests in:
dEQP-VK.api.image_clearing.core.clear_color_image.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: make sure we only expose transfer features for formats we can use
Iago Toral Quiroga [Tue, 24 Mar 2020 09:35:05 +0000 (10:35 +0100)]
v3dv: make sure we only expose transfer features for formats we can use

We were already doing this, but this makes it more explicit.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: check support for transfer usage flags
Iago Toral Quiroga [Tue, 24 Mar 2020 08:57:02 +0000 (09:57 +0100)]
v3dv: check support for transfer usage flags

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: improve assert handling for fallback paths on meta copy/clear operations
Iago Toral Quiroga [Tue, 24 Mar 2020 07:59:53 +0000 (08:59 +0100)]
v3dv: improve assert handling for fallback paths on meta copy/clear operations

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: assert on vkCreateComputePipelines
Iago Toral Quiroga [Thu, 19 Mar 2020 10:34:33 +0000 (11:34 +0100)]
v3dv: assert on vkCreateComputePipelines

So we can quickly identify tests that crash because they use compute shaders

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: disable depth/stencil testing if we don't have a depth/stencil attachment
Iago Toral Quiroga [Thu, 19 Mar 2020 09:45:12 +0000 (10:45 +0100)]
v3dv: disable depth/stencil testing if we don't have a depth/stencil attachment

Also, remove obsolete FIXME.

Fixes:
dEQP-VK.fragment_operations.early_fragment.early_fragment_tests_stencil_no_attachment

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: drop incorrect assertion on number of clear values at render pass begin
Iago Toral Quiroga [Thu, 19 Mar 2020 09:11:28 +0000 (10:11 +0100)]
v3dv: drop incorrect assertion on number of clear values at render pass begin

There can be more clear values than attachments, we should just ignore them
in that case.

Fixes some tests in:
dEQP-VK.fragment_operations.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: use perp end caps rasterization mode for lines
Iago Toral Quiroga [Thu, 19 Mar 2020 08:16:01 +0000 (09:16 +0100)]
v3dv: use perp end caps rasterization mode for lines

This is required to pass line rasterization tests in CTS while exposing
at least 4 bits of subpixel precision, which is the minimum required
by the spec. We are currently exposing 6 bits, however, if we select
diamond exit instead of perp end caps rasterization, then even if we
lower subpixel precision bits to 4 bits, we'd still fail one of the tests.

Fixes:
dEQP-VK.rasterization.flatshading.line_strip
dEQP-VK.rasterization.flatshading.lines
dEQP-VK.rasterization.interpolation.basic.line_strip
dEQP-VK.rasterization.interpolation.basic.lines
dEQP-VK.rasterization.interpolation.projected.line_strip
dEQP-VK.rasterization.interpolation.projected.lines

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: only emit config bits and varyings packets if needed
Iago Toral Quiroga [Thu, 19 Mar 2020 07:19:39 +0000 (08:19 +0100)]
v3dv: only emit config bits and varyings packets if needed

These should be emitted only if we have a new pipeline.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv/cmd_bufffer: rename and split emit_graphics_pipeline
Alejandro Piñeiro [Wed, 18 Mar 2020 14:53:24 +0000 (15:53 +0100)]
v3dv/cmd_bufffer: rename and split emit_graphics_pipeline

The name suggests that this method emits the full graphics pipeline,
but that is not the case (ie: scissor is emitted at a different
point).

Right now that method is mostly emitting the gl_shader state plus some
other packets. So we just renamed it to emit_gl_shader_state, and move
the other packet emission to new emission methods.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: stencil state fixes
Iago Toral Quiroga [Wed, 18 Mar 2020 15:52:17 +0000 (16:52 +0100)]
v3dv: stencil state fixes

First this makes it so we only clear dirty stencil state if we actually
emit the stencil packets. Second, now we check if we need to emit stencil
whenever a new pipeline is bound, since a new pipeline may not change the
dynamic stencil state but might still be changing other aspects of stencil,
which means that even if the dynamic stencil state is not dirty, we might
still need to emit new stencil packets.

This fixes a regression in VkRunner test depth-buffer.vk_shader_test after
we dropped the redundant emission of stencil state, since that redundant
emission was happening unconditionally whenever we had a new pipeline.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: drop redundant emission of stencil state
Iago Toral Quiroga [Wed, 18 Mar 2020 12:33:28 +0000 (13:33 +0100)]
v3dv: drop redundant emission of stencil state

If needed we are already calling this at draw time since stencil
can be dynamic state.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: rewrite dirty state handling
Iago Toral Quiroga [Wed, 18 Mar 2020 12:03:26 +0000 (13:03 +0100)]
v3dv: rewrite dirty state handling

The current implementation assumed that we would clear all dirty state
after we have emitted a pipeline, but that is not always true. In
particular, we don't emit blend constants unless we need them, so we
can't clear its dirty bit until we have bound a pipeline that actually
requires them.

The change implemented here has individual emit functions clear pipeline
states they hadle as they emit the corresponding state and we clear
the dirty pipeline bit at the end.

This fixes some CTS pipeline blend tests where we have multiple draws
with blending and only some of them require blend constants. In this case,
the original behavior would clear the blend constants dirty bit on draw
calls that don't actually emit blend constants (because they don't need
them), making the later draw calls that do need them fail because they
don't emit them either (since the previous draw calls cleared the dirty
bit).

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: only emit blend state if the pipeline is dirty
Iago Toral Quiroga [Wed, 18 Mar 2020 10:58:12 +0000 (11:58 +0100)]
v3dv: only emit blend state if the pipeline is dirty

Except for blend constants, which can be dynamic state.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: implement dynamic state for blend constants
Iago Toral Quiroga [Wed, 18 Mar 2020 10:50:47 +0000 (11:50 +0100)]
v3dv: implement dynamic state for blend constants

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: always flush draw calls if we are doing sRGB blending
Iago Toral Quiroga [Wed, 18 Mar 2020 09:41:19 +0000 (10:41 +0100)]
v3dv: always flush draw calls if we are doing sRGB blending

Not quite sure why this is required though. Conversion from/to
sRGB happens on tile loads and stores, with the tile buffer
being always linear, so there should be no difference.

Fixes all test failures in:
dEQP-VK.pipeline.blend.format.r8g8b8a8_srgb.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: add an 'always flush' mode
Iago Toral Quiroga [Wed, 18 Mar 2020 09:00:31 +0000 (10:00 +0100)]
v3dv: add an 'always flush' mode

In this mode, which can be activated with V3D_DEBUG=always_flush like
in the GL driver, we flush every draw call separately. For now this
is useful for debugging, but we can also set the flag internally on
specific jobs when we identify scenarios where we need the same behavior.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: only expose blending on formats that support it
Iago Toral Quiroga [Tue, 17 Mar 2020 13:21:17 +0000 (14:21 +0100)]
v3dv: only expose blending on formats that support it

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: implement color blending
Iago Toral Quiroga [Tue, 17 Mar 2020 11:10:58 +0000 (12:10 +0100)]
v3dv: implement color blending

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: fix depth/stencil clear color
Iago Toral Quiroga [Tue, 17 Mar 2020 13:38:57 +0000 (14:38 +0100)]
v3dv: fix depth/stencil clear color

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: fix copies and clears of 3D images
Iago Toral Quiroga [Mon, 16 Mar 2020 09:56:36 +0000 (10:56 +0100)]
v3dv: fix copies and clears of 3D images

3D images have a single layer and we should instead consider their depth.

Fixes some tests in:
dEQP-VK.synchronization.op.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: use vk_error() for all queue/submit errors
Iago Toral Quiroga [Fri, 13 Mar 2020 11:01:38 +0000 (12:01 +0100)]
v3dv: use vk_error() for all queue/submit errors

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: return OOM error if we fail to import or export sync objects
Iago Toral Quiroga [Fri, 13 Mar 2020 10:48:17 +0000 (11:48 +0100)]
v3dv: return OOM error if we fail to import or export sync objects

Typically, these functions would error out if we exceed the user limit
for open file descriptors, so this seems more appropriate.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: support submits without a command buffer
Iago Toral Quiroga [Fri, 13 Mar 2020 10:35:06 +0000 (11:35 +0100)]
v3dv: support submits without a command buffer

It is valid to submit with an empty list ofcommand buffers, however,
we still need to wait on the pWaitSemaphores provided and only signal
the pSignalSemaphores and fence once we have finished waiting on them
to honor the semantics of the submission.

Because waiting and signaling happens in the kernel, the easiest way
to do this is to submit a trivial no-op job to the GPU. To do this,
we need to refactor some of our code so that code that might have been
operating on a command buffer starts operating on a job instead, so we
can resuse most of our infrastructure to create the no-op job.

Additionally, because no-op jobs are created internally by the driver,
we are responsible for destroying them too. For this, we bind a fence
to each no-op job we submit and we test for completion of in-flight
no-op jobs (and destory them if completed) every time vkQueueSubmit
is called.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: only export the last job sync object once
Iago Toral Quiroga [Fri, 13 Mar 2020 09:38:31 +0000 (10:38 +0100)]
v3dv: only export the last job sync object once

Instead of exporting the very same object once per signal semaphore

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: handle the case where we fail to allocate a new job gracefully
Iago Toral Quiroga [Thu, 12 Mar 2020 10:59:04 +0000 (11:59 +0100)]
v3dv: handle the case where we fail to allocate a new job gracefully

There are a handful of tests that simulate 'out of memory' situations
during swapchain image creation, and these can lead to failed job
allocations when the driver is running on the prime blit path, as that
involves creating a command buffer. The tests expect us to handle this
scenario gracefully and return an appropriate OOM error as a result.
This make sure we don't try to dereference a job if we failed to allocate
it so we don't crash and can return the OOM error gracefully in the
process.

Fixes:
dEQP-VK.wsi.xlib.swapchain.simulate_oom.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: don't leak job allocations
Iago Toral Quiroga [Thu, 12 Mar 2020 10:53:13 +0000 (11:53 +0100)]
v3dv: don't leak job allocations

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: work around viewport Z scale hardware bug
Iago Toral Quiroga [Thu, 12 Mar 2020 08:36:24 +0000 (09:36 +0100)]
v3dv: work around viewport Z scale hardware bug

It looks like when the Z scale is small enough the hardware clipper
won't work properly.

Fixes:
dEQP-VK.draw.inverted_depth_ranges.nodepthclamp_deltazero

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: fix viewport Z
Iago Toral Quiroga [Thu, 12 Mar 2020 08:06:16 +0000 (09:06 +0100)]
v3dv: fix viewport Z

Vulkan has Z NDC range in [0, 1], we where using OpenGL's [-1, 1].

Fixes:
dEQP-VK.draw.inverted_depth_ranges.nodepthclamp_deltasmall
dEQP-VK.draw.inverted_depth_ranges.nodepthclamp_deltaone

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: fix scissor outside viewport
Iago Toral Quiroga [Wed, 11 Mar 2020 15:24:15 +0000 (16:24 +0100)]
v3dv: fix scissor outside viewport

In this scenario we can end up generating a clip window where
the max coordinates are smaller than the min coordinates and the simulator
asserts.

Fixes:
dEQP-VK.draw.scissor.dynamic_scissor_outside_viewport
dEQP-VK.draw.scissor.static_scissor_outside_viewport

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: fix image tiling configuration
Iago Toral Quiroga [Wed, 11 Mar 2020 14:49:09 +0000 (15:49 +0100)]
v3dv: fix image tiling configuration

We were not doing this right for images created with VK_IMAGE_TILING_LINEAR.
Also, only assign a DRM modifier if the image has been created for WSI.

This fixes a bunch of CTS tests that use copies to linear images to verify
the result of rendering.

Fixes multiple failures in:
dEQP-VK.draw.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: drop assert for map of a mapped buffer
Iago Toral Quiroga [Wed, 11 Mar 2020 11:56:34 +0000 (12:56 +0100)]
v3dv: drop assert for map of a mapped buffer

This triggers when dumping CLIF because the dump process involves
internally mapping all the BOs. We could unmap them there after we
are done, but there is really no reason why we need to assert on this,
so let's just keep things simple and unmap. If the user is really
double mapping, that should be caught by the validation layers.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: drop incorrect assertion
Iago Toral Quiroga [Wed, 11 Mar 2020 07:37:48 +0000 (08:37 +0100)]
v3dv: drop incorrect assertion

It is possible to specify a depth/stencil clear but then have no
actual depth/stencil attachment used in the subpass. In that case
we are already skipping the store.

Fixes:
dEQP-VK.renderpass.suballocation.unused_clear_attachments.*depthonly_unused

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: don't assume that VkPipelineColorBlendStateCreateInfo is provided
Iago Toral Quiroga [Tue, 10 Mar 2020 11:41:41 +0000 (12:41 +0100)]
v3dv: don't assume that VkPipelineColorBlendStateCreateInfo is provided

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: lower {i,u}mulExtended
Iago Toral Quiroga [Tue, 10 Mar 2020 11:19:48 +0000 (12:19 +0100)]
v3dv: lower {i,u}mulExtended

Fixes:
dEQP-VK.glsl.builtin.function.integer.imulextended.*
dEQP-VK.glsl.builtin.function.integer.umulextended.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: lower usubborrow and uaddcarry
Iago Toral Quiroga [Tue, 10 Mar 2020 11:03:19 +0000 (12:03 +0100)]
v3dv: lower usubborrow and uaddcarry

For some reason our backend compiler doesn't have an implementation for
usubborrow, only for uaddcarry. We could add it, however, the existing
uaddcarry implementation also seems to fail some of the CTS tests,
which pass if we lower.

Fixes:
dEQP-VK.glsl.builtin.function.integer.uaddcarry.*
dEQP-VK.glsl.builtin.function.integer.usubborrow.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: split fragment shader array outputs
Iago Toral Quiroga [Tue, 10 Mar 2020 08:51:48 +0000 (09:51 +0100)]
v3dv: split fragment shader array outputs

Our backend expects that our output variables are not arrays so we can
track the variable that writes to each output location separately.

Fixes:
dEQP-VK.glsl.440.linkage.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv/device: tweak ssbo/ubo device limits
Alejandro Piñeiro [Fri, 6 Mar 2020 12:39:36 +0000 (13:39 +0100)]
v3dv/device: tweak ssbo/ubo device limits

They still need some review to get some real final values, but what we
had before were somewhat too low. Increasing them a little. This
allows to get some CTS tests from skip to pass, which afais they are
using reasonable values.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: fix incorrect sizing of the vertex attribute state array
Iago Toral Quiroga [Fri, 6 Mar 2020 11:21:34 +0000 (12:21 +0100)]
v3dv: fix incorrect sizing of the vertex attribute state array

Fixes crashes in:
dEQP-VK.glsl.conversions.matrix_combine.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: call nir_lower_io_arrays_to_elements_no_indirects on vertex shaders
Iago Toral Quiroga [Fri, 6 Mar 2020 10:11:55 +0000 (11:11 +0100)]
v3dv: call nir_lower_io_arrays_to_elements_no_indirects on vertex shaders

This gets us to split matrix vertex inputs with direct access to
vectors, which the backend compiler expects. The GL driver seems to
rely on this too, which is called by the Mesa state tracker.

Cases with indirect cases seem to be handled at link time via
nir_lower_io_arrays_to_elements, which we are already calling.

Fixes crashes in:
dEQP-VK.glsl.conversions.matrix_to_matrix.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3d/compiler: implement nir_op_fquantize2f16
Iago Toral Quiroga [Thu, 5 Mar 2020 12:00:11 +0000 (13:00 +0100)]
v3d/compiler: implement nir_op_fquantize2f16

Reviewd-by: Alejandro Piñeiro <apinheiro@igalia.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv/descriptor: take into account pPushConstantRanges
Alejandro Piñeiro [Wed, 4 Mar 2020 14:38:55 +0000 (15:38 +0100)]
v3dv/descriptor: take into account pPushConstantRanges

Push constant tests were still working without taking this into
account because we can't really fine graine how much we allocate for
them.

For now we only use them to know if we should allocate/fill the ubo
for push constants or not.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: implement interpolation qualifiers
Iago Toral Quiroga [Thu, 5 Mar 2020 09:48:33 +0000 (10:48 +0100)]
v3dv: implement interpolation qualifiers

Also, Vulkan uses the same provoking vertex rules are Direct3D, which
changes from OpenGL's default. Make sure we honor that.

Fixes:
dEQP-VK.spirv_assembly.instruction.graphics.cross_stage.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: add a no-op fragment shader if we don't have one
Iago Toral Quiroga [Wed, 4 Mar 2020 14:53:44 +0000 (15:53 +0100)]
v3dv: add a no-op fragment shader if we don't have one

Fixes: dEQP-VK.pipeline.vertex_only.position_to_ssbo
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv/pipeline: clean up io lowering
Alejandro Piñeiro [Wed, 4 Mar 2020 11:40:15 +0000 (12:40 +0100)]
v3dv/pipeline: clean up io lowering

We had 4 really small functions for the io lowering (which main
purpose is getting locations assigned).

This commit merge them to 2 slightly bigger functions. It also fix a
typo were a vs lowering was calling nir_assign_io_var_locations using
MESA_SHADER_FRAGMENT.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv/pipeline: revamp nir lowering/optimizations passes
Alejandro Piñeiro [Tue, 3 Mar 2020 12:38:11 +0000 (13:38 +0100)]
v3dv/pipeline: revamp nir lowering/optimizations passes

The main reason is getting nir_lower_io_to_temporaries and
nir_opt_peephole_select to get some switch/ifelse with store outputs
simplified out, as some tests were failing because the v3d compiler
was not able to handle them.

As this needed some extra lowerings to get that working, we are also
revamping the full nir processing.

Heavily based on intel preprocess/optimize nir passes.

As mentioned on some other v3dv commits, some of this work could be
done by adding those passes to the v3d compiler, allowing to avoid
some duplication. But at this point we prefer to keep the v3d compiler
untouched as much as possible. This could be revisited on the future.

We also remove some passes that are unnedeed or we already know are
called by v3d_compiler.  Although we try to not add too many passes,
we are already adding passes in advance that we think that would be
useful in the near-term.

Among others, gets the following tests working:
  dEQP-VK.binding_model.descriptor_copy.graphics.storage*
  dEQP-VK.binding_model.descriptor_copy.graphics.uniform*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: drop incorrect assertion
Iago Toral Quiroga [Wed, 4 Mar 2020 10:14:47 +0000 (11:14 +0100)]
v3dv: drop incorrect assertion

This was intended to check that we only got
VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT
on secondary command buffers, but the spec states that this flag
should be ignored for primary command buffers.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: don't reset loader data on command buffers
Iago Toral Quiroga [Wed, 4 Mar 2020 10:12:08 +0000 (11:12 +0100)]
v3dv: don't reset loader data on command buffers

We were clearing memory to 0 on create and reset, including the
loader data, which is not correct on reset since it would cleat
the loader dispatch table for the command buffer. We should only
clear driver data.

Also, don't use vk_zalloc for the command buffer allocation, since
we are already clearing on reset and we always reset when we begin
recording.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: assign driver locations on fragment shader output variables
Iago Toral Quiroga [Wed, 4 Mar 2020 08:29:28 +0000 (09:29 +0100)]
v3dv: assign driver locations on fragment shader output variables

We were getting driver location 0 on all output variables, which meant
that our color writes were always being redirected to render target 0.

Fixes dEQP-VK.pipeline.framebuffer_attachment.diff_* which uses multiple
render targets.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: trivial refactors in a few meta copy helpers
Iago Toral Quiroga [Tue, 3 Mar 2020 11:26:52 +0000 (12:26 +0100)]
v3dv: trivial refactors in a few meta copy helpers

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: more frame tiling refactors
Iago Toral Quiroga [Tue, 3 Mar 2020 10:57:59 +0000 (11:57 +0100)]
v3dv: more frame tiling refactors

This puts all the information required to setup frame tiling into
v3dv_frame_tiling so we no longer need a framebuffer to start a
frame. This makes the code simpler, since frame tiling calculations
happen automatically when we start a new frame and simplifies
the implementation of copy and clear operations that used to
requiere that we setup a fake framebuffer with no actual attachments,
which was a bit of a kludge.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: rewrite frame tiling setup
Iago Toral Quiroga [Mon, 2 Mar 2020 16:21:26 +0000 (17:21 +0100)]
v3dv: rewrite frame tiling setup

So far we have been getting away with computing frame tiling information for
the framebuffer object, but that is not correct, since different subpasses
may access different subsets of the framebuffer, with each requiring a
different configuration because the number of render targets and the maximum
bpp can change for each subpass.

This adds a v3dv_frame_tiling struct to keep the frame tiling information and
rewrites the code to compute this for every new job we start.

Fixes a bunch of tests in dEQP-VK.pipeline.render_to_image.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: fix subpass tracking in the command buffer state
Iago Toral Quiroga [Mon, 2 Mar 2020 11:08:19 +0000 (12:08 +0100)]
v3dv: fix subpass tracking in the command buffer state

When we create a new job for a new subpass, we might have to finish
the current job for the previous subpass, so it is important that we
we don't get ahead of ourselves and increment the current subpass index
in the command buffer state until we are really done finishing the
previous job.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: fix framebuffer format when computing fragment shader key
Iago Toral Quiroga [Mon, 2 Mar 2020 10:50:44 +0000 (11:50 +0100)]
v3dv: fix framebuffer format when computing fragment shader key

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: take memory format from appropriate miplevel for image load/store
Iago Toral Quiroga [Mon, 2 Mar 2020 09:13:14 +0000 (10:13 +0100)]
v3dv: take memory format from appropriate miplevel for image load/store

We were storing the format of the base miplevel in the image view and
we were typically using that instead of the taking the format from
the appropriate image slice. This was a problem when loading or storing
a miplevel other than the base which happened to have a different format.

This also removed the tiling field from the image view to avoid repeating
the same mistake in the future.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv/descriptor: support for dynamic ubo/ssbo
Alejandro Piñeiro [Mon, 24 Feb 2020 10:32:57 +0000 (11:32 +0100)]
v3dv/descriptor: support for dynamic ubo/ssbo

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: fix supertile coverage when render are size is 0.
Iago Toral Quiroga [Fri, 28 Feb 2020 07:52:22 +0000 (08:52 +0100)]
v3dv: fix supertile coverage when render are size is 0.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: implement vkGetRenderAreaGranularity
Iago Toral Quiroga [Thu, 27 Feb 2020 12:07:15 +0000 (13:07 +0100)]
v3dv: implement vkGetRenderAreaGranularity

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: fix fill buffer with VK_WHOLE_SIZE
Iago Toral Quiroga [Thu, 27 Feb 2020 11:25:16 +0000 (12:25 +0100)]
v3dv: fix fill buffer with VK_WHOLE_SIZE

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: don't support image formats that we can rendet to or texture from
Iago Toral Quiroga [Thu, 27 Feb 2020 11:18:41 +0000 (12:18 +0100)]
v3dv: don't support image formats that we can rendet to or texture from

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: fix image clearing with VK_REMAINING_*
Iago Toral Quiroga [Thu, 27 Feb 2020 10:58:27 +0000 (11:58 +0100)]
v3dv: fix image clearing with VK_REMAINING_*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: don't use TLB path for formats that are not supported for rendering
Iago Toral Quiroga [Thu, 27 Feb 2020 10:34:48 +0000 (11:34 +0100)]
v3dv: don't use TLB path for formats that are not supported for rendering

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: don't swap R/B channels for VK_FORMAT_R5B6G5_UNORM_PACK16
Iago Toral Quiroga [Thu, 27 Feb 2020 08:31:50 +0000 (09:31 +0100)]
v3dv: don't swap R/B channels for VK_FORMAT_R5B6G5_UNORM_PACK16

This corresponds to PIPE_FORMAT_B5G6R5_UNORM, which is the format that
is natively supported. Also, we can't swap R/B on 3-channel images!

Also, we should rely on the v3dv format table for this rather than
pipe format descriptions since we specify the expected correct swizzles
there for all supported formats. This, for example, gets us correct
beahvior for things like VK_FORMAT_B4G4R4A4_UNORM_PACK16 without
needing to special case it.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: implement vkResetCommandPool
Iago Toral Quiroga [Thu, 27 Feb 2020 08:06:28 +0000 (09:06 +0100)]
v3dv: implement vkResetCommandPool

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: meet requirements for supported format features and properties
Iago Toral Quiroga [Thu, 27 Feb 2020 07:55:40 +0000 (08:55 +0100)]
v3dv: meet requirements for supported format features and properties

For now this is only about advertising what is required, many things
here still lack an implementation.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: declare that we support robust buffer access
Iago Toral Quiroga [Fri, 21 Feb 2020 08:33:03 +0000 (09:33 +0100)]
v3dv: declare that we support robust buffer access

This is actually mandatory for any implementation so there is no
point in not supporting it.

This probably doesn't work yet and we might need to patch the
compiler to emit bounds testing code for TMU accesses.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: adjust a few limits to comply with CTS minimum requirements
Iago Toral Quiroga [Fri, 21 Feb 2020 08:26:47 +0000 (09:26 +0100)]
v3dv: adjust a few limits to comply with CTS minimum requirements

We don't support 4-bit multisample yet, but we will at some point.
Also, remove point size granularity/range since we were not meeting the
minimum requires, we might want to review that in the future.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: implement host-side event handling functions
Iago Toral Quiroga [Wed, 26 Feb 2020 08:36:27 +0000 (09:36 +0100)]
v3dv: implement host-side event handling functions

I am not quite certain that this is the way to go though. Here, we are
expecting that the GPU can set/reset the event inside a command buffer
as a 1x1 pixel clear for example, however, there is still the question
of how we get to implement the command buffer wait on an event, since
reading the docs I haven't found any such functionality to be available.
We could think of implementing this by splitting the command buffer
into multiple jobs at the wait command, and then using a separate
thread for job submissions that would poll the event UBO before sending
it to the kernel, but that looks like a bit of a kludge.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: implement vk{Create,Destroy}BufferView
Iago Toral Quiroga [Wed, 26 Feb 2020 08:07:42 +0000 (09:07 +0100)]
v3dv: implement vk{Create,Destroy}BufferView

For now this is not particularly useful, since we can't bind this to
a texel buffer descriptor yet.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: destroy wsi device during physical device termination
Iago Toral Quiroga [Mon, 24 Feb 2020 16:16:09 +0000 (17:16 +0100)]
v3dv: destroy wsi device during physical device termination

Fixes dEQP-VK.api.device_init.create_instance_device_intentional_alloc_fail

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: implement vkQueueWaitIdle
Iago Toral Quiroga [Fri, 21 Feb 2020 15:18:17 +0000 (16:18 +0100)]
v3dv: implement vkQueueWaitIdle

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: honor swizzle for non-copy operations of color formats
Iago Toral Quiroga [Thu, 20 Feb 2020 15:57:41 +0000 (16:57 +0100)]
v3dv: honor swizzle for non-copy operations of color formats

This gets clears of BGRA images to work.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: add assertions for unimplemented fallback paths
Iago Toral Quiroga [Thu, 20 Feb 2020 15:12:59 +0000 (16:12 +0100)]
v3dv: add assertions for unimplemented fallback paths

This helps with identifying tests that fail on supported paths from tests
that hit unimplemented paths in the driver.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: implement vkResetCommandBuffer
Iago Toral Quiroga [Thu, 20 Feb 2020 08:53:32 +0000 (09:53 +0100)]
v3dv: implement vkResetCommandBuffer

Also, implement implicit reset via vkCmdBeginCommandBuffer.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: initialize in_sync_bcl in our submits
Iago Toral Quiroga [Wed, 19 Feb 2020 11:28:21 +0000 (12:28 +0100)]
v3dv: initialize in_sync_bcl in our submits

We were not doing this and that could lead to the kernel refusing the
job if this happened to be gargabe. Make it zero, meaning that we don't
want to keep our bin jobs waiting for anything.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: add support for primitive restarts on indexed draw calls
Iago Toral Quiroga [Tue, 18 Feb 2020 10:08:44 +0000 (11:08 +0100)]
v3dv: add support for primitive restarts on indexed draw calls

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: implement indirect draws
Iago Toral Quiroga [Tue, 18 Feb 2020 08:31:39 +0000 (09:31 +0100)]
v3dv: implement indirect draws

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: add an assert to catch applications trying to clear invalid aspects
Iago Toral Quiroga [Mon, 17 Feb 2020 15:07:32 +0000 (16:07 +0100)]
v3dv: add an assert to catch applications trying to clear invalid aspects

I accidentally tried to clear D+S of a depth-only image which was not caught
by the validation layers in my environment. This made the simulator crash, but
tracking down the crash to the actual error was not trivial. This should make
it immediately obvious.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: vkCmdCopyBufferToImage for depth/stencil formats
Iago Toral Quiroga [Mon, 17 Feb 2020 14:39:20 +0000 (15:39 +0100)]
v3dv: vkCmdCopyBufferToImage for depth/stencil formats

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: implement vkCmdCopyBufferToImage for color formats
Iago Toral Quiroga [Mon, 17 Feb 2020 07:08:47 +0000 (08:08 +0100)]
v3dv: implement vkCmdCopyBufferToImage for color formats

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv/cmd_buffer: support for push constants
Alejandro Piñeiro [Fri, 11 Sep 2020 21:26:07 +0000 (23:26 +0200)]
v3dv/cmd_buffer: support for push constants

By default they are trivially lowered to load_uniform.

We still need to allocate an UBO for push constants, used for those
that are accessed using a non-const index. This is automatically
handled by the compiler, as it cames back as asking a
QUNIFORM_UBO_ADDR. This is what already does for gallium.

Note that if needing the UBO, we are uploading the full push constant
data. An improvement would be to try to upload only the data that
needs to rely on the UBO (so non-const accesses to uniforms).

Also, the code is not handling getting out of space from the UBO
bo. This would be tackled at a different commit.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3d/compiler: handle GL/Vulkan differences in uniform handling
Alejandro Piñeiro [Fri, 11 Sep 2020 21:42:19 +0000 (23:42 +0200)]
v3d/compiler: handle GL/Vulkan differences in uniform handling

This also adds a v3d_execution_environment, so compiler could know if
it is generating code for OpenGL or Vulkan needs.

Reviewed-by: Iago Toral <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: implement vkCmdClearDepthStencilImage
Iago Toral Quiroga [Thu, 13 Feb 2020 16:49:34 +0000 (17:49 +0100)]
v3dv: implement vkCmdClearDepthStencilImage

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: fix buffer automatic stride for image to buffer copies
Iago Toral Quiroga [Thu, 13 Feb 2020 10:34:09 +0000 (11:34 +0100)]
v3dv: fix buffer automatic stride for image to buffer copies

When the client requests a tightly packet copy, we should take
the stride from the size of the region to copy, not from the size
of the image (which can be larger).

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: implement vkCmdClearColorImage
Iago Toral Quiroga [Thu, 13 Feb 2020 08:40:27 +0000 (09:40 +0100)]
v3dv: implement vkCmdClearColorImage

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: implement vkCmdCopyImage
Iago Toral Quiroga [Wed, 12 Feb 2020 15:21:39 +0000 (16:21 +0100)]
v3dv: implement vkCmdCopyImage

As with vkCmdCopyImageToBuffer, this implements a fast path using the
TLB for the case where we are copying images from offset (0, 0). We
don't have the fallback path for other cases yet.

For this we need to rethink a bit our loads and stores so we can handle
depth/stencil copies correctly. Specifically, we are expected to do
different things depending on whether we are copying to a linear buffer
or to an image.

When copying depth/stencil to a buffer, we can only copy one aspect
at a time and the result should be tightly packed in the destination
buffer.

When copying depth/stencil to an image, we can copy one or both aspects,
and we need to write them in the corresponding aspect of the destination
image.

Because we can't do stores from the Z/S tile buffers in raster format,
we need to do image to buffer copies of these aspects using the a color
tile buffer and a compatible color format. However, when we are copying
to another image, since we need to write the channels in the corresponding
aspect of the destination image, we need to do this using by loading and
storing from an appropriate Z/S tile buffer.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: fix copy size for image to buffer copies
Iago Toral Quiroga [Wed, 12 Feb 2020 12:10:59 +0000 (13:10 +0100)]
v3dv: fix copy size for image to buffer copies

For some reason we were ignoring the extent to copy that was
passed in the region to copy and instead we were computing a
a region based on the image size and the selected miplevel.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

4 years agov3dv: refactor common code in meta copy operations
Iago Toral Quiroga [Wed, 12 Feb 2020 09:07:36 +0000 (10:07 +0100)]
v3dv: refactor common code in meta copy operations

Creates internal helpers to avoid replicating code in various places
and uses the fake framebuffer to pre-compute supertile coverage.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>