platform/upstream/mesa.git
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>

4 years agov3dv: add a concept of a fake framebuffer for meta-copy operations
Iago Toral Quiroga [Wed, 12 Feb 2020 08:23:53 +0000 (09:23 +0100)]
v3dv: add a concept of a fake framebuffer for meta-copy operations

This is mostly to simplify some of the code and avoid the need to pass
the internal type of our single render target to every function in the
chain.

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

4 years agov3dv: move the framebuffer setup code for buffer copy/fill to a helper
Iago Toral Quiroga [Wed, 12 Feb 2020 08:07:24 +0000 (09:07 +0100)]
v3dv: move the framebuffer setup code for buffer copy/fill to a helper

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

4 years agov3dv: implement vkCmdFillBuffer
Iago Toral Quiroga [Wed, 12 Feb 2020 07:25:20 +0000 (08:25 +0100)]
v3dv: implement vkCmdFillBuffer

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

4 years agov3dv: implement vkCmdUpdateBuffer
Iago Toral Quiroga [Tue, 11 Feb 2020 14:12:32 +0000 (15:12 +0100)]
v3dv: implement vkCmdUpdateBuffer

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

4 years agov3dv: implement vkCmdCopyBuffer
Iago Toral Quiroga [Mon, 10 Feb 2020 11:39:10 +0000 (12:39 +0100)]
v3dv: implement vkCmdCopyBuffer

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

4 years agov3dv: don't advertise texel buffer support yet.
Iago Toral Quiroga [Mon, 10 Feb 2020 09:00:17 +0000 (10:00 +0100)]
v3dv: don't advertise texel buffer support yet.

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

4 years agov3dv: Add more supported formats to our format table
Iago Toral Quiroga [Mon, 10 Feb 2020 08:42:29 +0000 (09:42 +0100)]
v3dv: Add more supported formats to our format table

Some of these may need additional work to work for real, but we should
be able to support them.

We also include some formats that are not supported for images, but
that we want to support for buffers, such as R32G32B32 for a vertex
buffer.  In the future we might want to expand the format table to
specify which formats are supported for buffers.

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

4 years agov3dv: no need to manually add assembly bo to the job
Alejandro Piñeiro [Sat, 8 Feb 2020 22:12:56 +0000 (23:12 +0100)]
v3dv: no need to manually add assembly bo to the job

The _cl utility methods are already doing that implicitly, as a way to
ensure that any address emitted gets its bo included on the job.

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

4 years agov3dv: take the number of layers from the framebuffer
Iago Toral Quiroga [Fri, 7 Feb 2020 11:59:37 +0000 (12:59 +0100)]
v3dv: take the number of layers from the framebuffer

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

4 years agov3dv: ignore image view aspects for depth/stencil attachments
Iago Toral Quiroga [Fri, 7 Feb 2020 11:24:18 +0000 (12:24 +0100)]
v3dv: ignore image view aspects for depth/stencil attachments

 From the Vulkan spec:

   "When an image view of a depth/stencil image is used as a
    depth/stencil framebuffer attachment, the aspectMask is ignored
    and both depth and stencil image subresources are used."

So in that scenario, we ignore the aspect mask on the view and go
check the actual format of the underlying image to decide if we
have depth or depth+stencil aspects.

This gets VkRunner's depth-buffer.shader_test to pass.

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

4 years agov3dv: fix clockwise primitive setting
Iago Toral Quiroga [Fri, 7 Feb 2020 10:06:15 +0000 (11:06 +0100)]
v3dv: fix clockwise primitive setting

It looks like the hardware does this backwards. The GL driver
also reverses it.

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

4 years agov3dv: implement indexed draws
Iago Toral Quiroga [Fri, 7 Feb 2020 09:10:39 +0000 (10:10 +0100)]
v3dv: implement indexed draws

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

4 years agov3dv: implement vkCmdClearAttachments
Iago Toral Quiroga [Thu, 6 Feb 2020 11:39:48 +0000 (12:39 +0100)]
v3dv: implement vkCmdClearAttachments

For now this only implements a fast path using the tile buffer, so it
can only be used when clearing full images, but this is good enough
for VkRunner.

The implementation is a bit tricky because this command executes
inside a render pass, and yet, since we are using the tile buffer to
clear, this needs to go in its own job. This means that with this, we
need to be able to split a subpass into multiple jobs which creates
some issues.

For example, certain operations, such as the subpass load operation
(particularly if it is a clear) should only happen on the first job of
the subpass and subsequent jobs in the same subpass should always
load.

Similarly, we should not discard the last store on an attachment
unless we know it is the last job for the last subpass that uses the
attachment.

To handle these cases we add two new flags to the job, one to know if
the job is not the first in a subpass (is_subpass_continue) and
another one to know if a job is the last in a subpass
(is_subpass_finish).

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

4 years agov3dv: add a helper to get the Z/S buffer from an aspect mask
Iago Toral Quiroga [Thu, 6 Feb 2020 11:36:48 +0000 (12:36 +0100)]
v3dv: add a helper to get the Z/S buffer from an aspect mask

We will be using this when we need to implement other clearing commands.

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

4 years agov3dv: add a helper to compute the hardware clear color
Iago Toral Quiroga [Thu, 6 Feb 2020 11:34:15 +0000 (12:34 +0100)]
v3dv: add a helper to compute the hardware clear color

We will be using this when we implement other clearing commands
(currently this is only used for the atatchment load clear operation).

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

4 years agov3dv/pipeline: null check for pCreateInfo->pDepthStencilState
Alejandro Piñeiro [Wed, 5 Feb 2020 21:47:21 +0000 (22:47 +0100)]
v3dv/pipeline: null check for pCreateInfo->pDepthStencilState

This prevents a crash when the validation layers are enabled for some
of our ubo tests. Again, it seems that if some attachments are
missing, the validation layers remove some of the structs from the
pCreateInfo.

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

4 years agov3dv/descriptor_set: support for array of ubo/ssbo
Alejandro Piñeiro [Thu, 13 Feb 2020 21:22:18 +0000 (22:22 +0100)]
v3dv/descriptor_set: support for array of ubo/ssbo

For that we include the array_index when asking for a ubo/ssbo index
from the descriptor_map.

Until now, array_index was not included, but the descriptor_map took
into account the array_size. This had the advantage that you only need
a entry on the descriptor map, and the index was properly return.

But this make it complex to get back the set, binding and array_index
back from the ubo/ssbo binding. So it was more easy to just add
array_index. Somehow now the "key" on the descriptor map is the
combination of (set, binding, array_index).

Note that this also make sense as the vulkan api identifies each array
index as a descriptor, so for example, from spec,
VkDescriptorSetLayoutBinding:descriptorCount

 "descriptorCount is the number of descriptors contained in the
  binding, accessed in a shader as an array"

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

4 years agov3dv: initial descriptor set support
Alejandro Piñeiro [Mon, 20 Jan 2020 14:29:38 +0000 (15:29 +0100)]
v3dv: initial descriptor set support

Focused on getting the basic UBO and SSBO cases implemented. So no
dynamic offset, push contanst, samplers, and so on.

This include a initial implementation for CreatedescriptorPool,
CreateDescriptorSetLayout, AllocateDescriptorSets,
UpdateDescriptorSets, CreatePipelineLayout, and CmdBindDescriptorSets.

Also introduces lowering vulkan intrinsics. For now just
vulkan_resource_index.

We also introduce a descriptor_map, in this case for the ubos and
ssbos, used to assign a index for each set/binding combination, that
would be used when filling back the details of the ubo or ssbo on
other places (like QUNIFORM_UBO_ADDR or QUNIFORM_SSBO_OFFSET).

Note that at this point we don't need a bo for the descriptor pool, so
descriptor sets are not getting a piece of it. That would likely
change as we start to support more descriptor set types.

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

4 years agov3dv: debug nir shader also after spirv_to_nir
Alejandro Piñeiro [Tue, 21 Jan 2020 14:45:39 +0000 (15:45 +0100)]
v3dv: debug nir shader also after spirv_to_nir

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

4 years agov3dv: fix the mess with dynamic state handling
Iago Toral Quiroga [Wed, 5 Feb 2020 09:53:20 +0000 (10:53 +0100)]
v3dv: fix the mess with dynamic state handling

The general idea is that we always emit from our dynamic state, and when
a particular piece of state is not dynamic, we just set our dynamic state
from the pipeline state, however, the implementation was quite confusing:
the mask of dynamic states flagged states that were not dynamic and some
places woud mix dirty flags and dynamic state flags. We also were not
updating the dynamic state mask in the command buffer, etc.

This patch, hopefully, simplifies all this and makes it less confusing,
starting by making the dynamic state mask flag dynamic states, fixing
the places where we would confuse dirty state flags with dynamic state
flags, making sure that our command buffer state is setup correctly
and that we only emit state when it is actually dirty.

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

4 years agov3dv: implement dynamic stencil states
Iago Toral Quiroga [Tue, 4 Feb 2020 16:43:49 +0000 (17:43 +0100)]
v3dv: implement dynamic stencil states

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

4 years agov3dv: clamp stencil masks and reference value to supported limits
Iago Toral Quiroga [Tue, 4 Feb 2020 10:24:21 +0000 (11:24 +0100)]
v3dv: clamp stencil masks and reference value to supported limits

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

4 years agov3dv: implement early Z optimization
Iago Toral Quiroga [Tue, 4 Feb 2020 09:26:04 +0000 (10:26 +0100)]
v3dv: implement early Z optimization

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

4 years agov3dv: fix viewport state from pipeline
Iago Toral Quiroga [Mon, 3 Feb 2020 11:55:25 +0000 (12:55 +0100)]
v3dv: fix viewport state from pipeline

We were not computing viewport transform for static viewports provided with
the pipeline state. Also, we were not copying the transform into the command
buffer state when we bound the pipeline.

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

4 years agov3dv: support copying depth/stencil aspects to buffer
Iago Toral Quiroga [Fri, 31 Jan 2020 09:02:26 +0000 (10:02 +0100)]
v3dv: support copying depth/stencil aspects to buffer

Just as with color copies, we only support tile buffer copies for now,
so we can only copy regions that start at offset (0,0).

Because the hardware doesn't support storing depth/stencil buffers to
raster format, we need to load and store our data to/from the tile
buffer as a compatible color format instead.

The Vulkan spec also has specific expectations regarding placement
of X8/S8 bits in 24-bit depth formats which don't match the hardware's
so these formats require specific work so we can swizzle channels
to match the Vulkan spec.

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

4 years agov3dv: fix indentation
Iago Toral Quiroga [Thu, 30 Jan 2020 08:30:20 +0000 (09:30 +0100)]
v3dv: fix indentation

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

4 years agov3dv/bo: add a bo name
Alejandro Piñeiro [Thu, 30 Jan 2020 11:24:55 +0000 (12:24 +0100)]
v3dv/bo: add a bo name

This is only used when doing a clif/cle dump, but makes it far easier
to understand.

Most names are the same that the ones used at v3d (CL, tile_alloc,
TDSA), except those that on v3d were labelled as "resource", as right
now we don't have a resource uploader that englobes different
things. In fact, the good thing of not having that uploader is that
individual bos has a more accurate description of their purpose.

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

4 years agov3dv: implement stencil testing
Iago Toral Quiroga [Wed, 29 Jan 2020 15:35:39 +0000 (16:35 +0100)]
v3dv: implement stencil testing

This works on combined depth/stencil formats only, separate stencil
is not supported yet.

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

4 years agov3dv: support depth testing on combined depth/stencil formats
Iago Toral Quiroga [Wed, 29 Jan 2020 11:44:57 +0000 (12:44 +0100)]
v3dv: support depth testing on combined depth/stencil formats

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

4 years agov3dv: select correct internal type for depth/stencil formats
Iago Toral Quiroga [Wed, 29 Jan 2020 10:47:55 +0000 (11:47 +0100)]
v3dv: select correct internal type for depth/stencil formats

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

4 years agov3dv: select the depth/stencil buffer from the attachment aspect mask
Iago Toral Quiroga [Wed, 29 Jan 2020 09:13:40 +0000 (10:13 +0100)]
v3dv: select the depth/stencil buffer from the attachment aspect mask

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

4 years agov3dv: compute subpass ranges for attachments at render pass creation time
Iago Toral Quiroga [Tue, 28 Jan 2020 15:53:54 +0000 (16:53 +0100)]
v3dv: compute subpass ranges for attachments at render pass creation time

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

4 years agov3dv: don't always skip tile buffer stores
Iago Toral Quiroga [Tue, 28 Jan 2020 12:04:50 +0000 (13:04 +0100)]
v3dv: don't always skip tile buffer stores

Otherwise we would lose updates relevant to subsequent subpasses in
the same renderpass that read or partially write the attachment.

The only scenario where we can safely do this is on the last subpass
that uses the attachment, so long as we don't need to emit the store
for the clear.

This also fixes a bug in the computation of the first subpass that
uses an attachment.

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

4 years agov3dv: implement support for depth testing
Iago Toral Quiroga [Tue, 28 Jan 2020 12:03:41 +0000 (13:03 +0100)]
v3dv: implement support for depth testing

This ignores stencil for now and focuses on depth testing without
support for early depth testing.

To implement this we need to start considering how many of our
framebuffer attachments are color attachments, since some of the
computations we use to determine tile sizes and binning configuration
depend on this.

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

4 years agov3dv: don't swap RB channels when copying images to buffers
Iago Toral Quiroga [Thu, 23 Jan 2020 12:01:58 +0000 (13:01 +0100)]
v3dv: don't swap RB channels when copying images to buffers

We don't need to do this, since we are just copying. Also, we are not
swapping on the store, so doing it on the load would be incorrect.
This gets the prime blit present path in WSI common to render R/B
channels correctly after blitting from the BGRA image to the linear
buffer for display output.

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

4 years agov3dv: rename drm device fields so they are more explict
Iago Toral Quiroga [Thu, 23 Jan 2020 10:59:28 +0000 (11:59 +0100)]
v3dv: rename drm device fields so they are more explict

Also, remove references to the master_fd. This is only useful for
VK_KHR_display which we are not currently implementing.

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

4 years agov3dv: allocate winsys BOs properly
Iago Toral Quiroga [Thu, 23 Jan 2020 10:24:05 +0000 (11:24 +0100)]
v3dv: allocate winsys BOs properly

When running on real hardware we need to allocate winsys buffers on
the display device and import them into the v3d device for rendering.

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

4 years agov3dv: implement device detection on actual hardware
Iago Toral Quiroga [Mon, 20 Jan 2020 09:45:06 +0000 (10:45 +0100)]
v3dv: implement device detection on actual hardware

When running on the real hardware we have two devices: the v3d render
node and the vc4 display node. We need the latter to allocate
winsys BOs for v3d to render into. Since exporting these BOs is
a privileged operation, we need to obtain the fd for this device
through the display server. For now we only support doing this through
the XCB DRI3 platform.

Also, do not duplicate or re-open the DRM devices when creating logical
devices. The simulator checks that the file descriptor is exactly
the same we used to initialize it when we created the physical device
and aborts if it sees a different fd number, even if it points to the
same device.

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

4 years agov3dv/pipeline: adding some nir-based linking
Alejandro Piñeiro [Fri, 17 Jan 2020 12:36:22 +0000 (13:36 +0100)]
v3dv/pipeline: adding some nir-based linking

Among other things, gets a constants output from a vs, used as input
to a fs, to get lowered and moved as a load const on the fs.

Heavily based on st_glsl_to_nir, already used by the v3d
driver. Slightly adapted to our needs, but there are still room for
customization.

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

4 years agov3d/cmd_buffer: emit flat_shade/noperspective/centroid flags
Alejandro Piñeiro [Thu, 16 Jan 2020 14:28:17 +0000 (15:28 +0100)]
v3d/cmd_buffer: emit flat_shade/noperspective/centroid flags

We just emit the default ZERO_ALL values, to cover at least the cases
where that is enough. Need to emit non-default values if needed.

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

4 years agov3dv: stubs for Create/DestroyPipelineCache
Alejandro Piñeiro [Thu, 16 Jan 2020 12:22:57 +0000 (13:22 +0100)]
v3dv: stubs for Create/DestroyPipelineCache

Good enough to avoid vkrunner crashing.

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

4 years agov3dv: hook up WSI support
Iago Toral Quiroga [Thu, 16 Jan 2020 10:14:17 +0000 (11:14 +0100)]
v3dv: hook up WSI support

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