Commit Graph

189 Commits

Author SHA1 Message Date
Iago Toral Quiroga d6afbcb800 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga aba2a66fb8 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 43c1fa492a 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga eac594baa5 v3dv: implement vkQueueWaitIdle
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 7c4827c1e2 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 204d06cc26 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 79569fb796 v3dv: implement vkResetCommandBuffer
Also, implement implicit reset via vkCmdBeginCommandBuffer.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga ea09600fe6 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 83554840a5 v3dv: add support for primitive restarts on indexed draw calls
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 914a23a8a0 v3dv: implement indirect draws
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 06fa2928b8 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 9a2d6cca76 v3dv: vkCmdCopyBufferToImage for depth/stencil formats
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga f13dd2e606 v3dv: implement vkCmdCopyBufferToImage for color formats
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00
Alejandro Piñeiro e9085e56ed 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>
2020-10-13 21:21:27 +00:00
Alejandro Piñeiro c8212731e7 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 4e2817fd33 v3dv: implement vkCmdClearDepthStencilImage
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 11310ee621 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 8da9da87a6 v3dv: implement vkCmdClearColorImage
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 1aa5fc0469 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga efbf91cb6c 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 1ee270f8c4 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga d39901f416 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 7a2544e2d4 v3dv: move the framebuffer setup code for buffer copy/fill to a helper
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 5ed78d91fe v3dv: implement vkCmdFillBuffer
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga b3f9a3beaf v3dv: implement vkCmdUpdateBuffer
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 2f0fbc747c v3dv: implement vkCmdCopyBuffer
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 18824bf23b v3dv: don't advertise texel buffer support yet.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga c7404f4e2d 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>
2020-10-13 21:21:27 +00:00
Alejandro Piñeiro 83e83257f8 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 3dff3f3a45 v3dv: take the number of layers from the framebuffer
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 0dc4416827 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 50652cb919 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 1c6938484e v3dv: implement indexed draws
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga f48788896e 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 255d4245fd 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 68692297ba 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>
2020-10-13 21:21:27 +00:00
Alejandro Piñeiro aa8a61f0ae 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>
2020-10-13 21:21:27 +00:00
Alejandro Piñeiro 34cf475102 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>
2020-10-13 21:21:27 +00:00
Alejandro Piñeiro 9afd24f89a 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>
2020-10-13 21:21:27 +00:00
Alejandro Piñeiro 7d6fbea536 v3dv: debug nir shader also after spirv_to_nir
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 29a7d99c4a 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 134afdfd32 v3dv: implement dynamic stencil states
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga d84458b5de v3dv: clamp stencil masks and reference value to supported limits
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 590f29349f v3dv: implement early Z optimization
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 72040f9182 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 8d143a0273 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 79b1b68488 v3dv: fix indentation
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00
Alejandro Piñeiro b44d4343ca 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga 55acd9f1ea 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>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga bb6e9d26dc v3dv: support depth testing on combined depth/stencil formats
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00