Commit Graph

129543 Commits

Author SHA1 Message Date
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
Iago Toral Quiroga c608e1350b v3dv: select correct internal type 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 0e59771339 v3dv: select the depth/stencil buffer from the attachment aspect mask
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:27 +00:00
Iago Toral Quiroga df34b8fac6 v3dv: compute subpass ranges for attachments at render pass creation time
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:26 +00:00
Iago Toral Quiroga a7a402c8bd 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>
2020-10-13 21:21:26 +00:00
Iago Toral Quiroga 4d0e497a3e 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>
2020-10-13 21:21:26 +00:00
Iago Toral Quiroga c005a18a56 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>
2020-10-13 21:21:26 +00:00
Iago Toral Quiroga 9a72a79d1c 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>
2020-10-13 21:21:26 +00:00
Iago Toral Quiroga 356cf8261e 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>
2020-10-13 21:21:26 +00:00
Iago Toral Quiroga 1d92c314f8 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>
2020-10-13 21:21:26 +00:00
Alejandro Piñeiro 1ae844c1c8 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>
2020-10-13 21:21:26 +00:00
Alejandro Piñeiro dc45d57c38 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>
2020-10-13 21:21:26 +00:00
Alejandro Piñeiro 6cac991d3f v3dv: stubs for Create/DestroyPipelineCache
Good enough to avoid vkrunner crashing.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:26 +00:00
Iago Toral Quiroga 6ab4c51d5c v3dv: hook up WSI support
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:26 +00:00
Iago Toral Quiroga c75846e674 v3dv: implement DRM modifier setup for WSI
This is only really relevant when running on real hardware, since
when we run on the simulator we don't care about the format of the
swapchain images.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:26 +00:00
Iago Toral Quiroga 4825a76a22 v3dv: implement vkGetImageSubresourceLayout
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:26 +00:00
Iago Toral Quiroga 54374f36df v3dv: fix copy image to buffer
If either of bufferRowLength or bufferImageHeight are zero, then that
aspect alone of the image is tighly packed. We were assuming that if
either was zero both aspects were tightly packed, which is wrong.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:26 +00:00
Iago Toral Quiroga beee18103e v3dv: implement VK_KHR_external_memory{_fd,_dma_buf}
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:26 +00:00
Iago Toral Quiroga 0fd434d977 v3dv: implement VK_KHR_external_memory_capabilities
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:26 +00:00
Alejandro Piñeiro 931b247a7c v3dv/format: add R32G32B32A32_SFLOAT format
This is clearly supported, and we already confirmed that work with
some of our tests.

Needed to avoid an assertion of such tests when validation layers are
enabled.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:26 +00:00
Iago Toral Quiroga 0fd72b6ac4 v3dv: implement VK_KHR_get_physical_device_properties2
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:26 +00:00
Iago Toral Quiroga ecd0b1f4b1 v3dv: include Vulkan version 1.1 as unsupported.
This is so we can generate entry points for extensions that have been
promoted to core in 1.1.

Entry points for promoted extensions are aliased without the KHR suffix
in the Vulkan API XML, and the entry point generation scripts are designed
to point the dispatch tables to entry points generated from the non-aliased
function names, however, these are not included in the header file without
this change.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:26 +00:00
Iago Toral Quiroga 5935ef098d v3dv: implement vkGetPhysicalDeviceSparseImageFormatProperties
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:26 +00:00
Alejandro Piñeiro 85f1f0690e v3dv: provide default values for input attributes
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:26 +00:00
Alejandro Piñeiro aad44cc614 v3dv: vertex input support
This includes:

   * Implementation for CmdBindVertexBuffers

   * Gather vertex input info during CreateGraphicsPipelines
     (pipeline_init) and SHADER_STATE_ATTRIBUTE_RECORD prepacking

   * Final emission of such packet during CmdDraw
     (cmd_buffer_emit_graphics_pipeline)

Default attributes values will be handled on a following patch.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:26 +00:00
Alejandro Piñeiro 8c4fcc2bf7 v3dv/pipeline: lower fs/vs inputs/outputs
For now mostly call to nir_assign_io_var_locations

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:26 +00:00
Iago Toral Quiroga 45875065fd v3dv: support queue submissions with multiple command buffers
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:26 +00:00
Iago Toral Quiroga 047ee913e8 v3dv: implement fences
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:26 +00:00
Iago Toral Quiroga 56b4eac8d6 v3dv: implement semaphore waits and signals on queue submissions
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-10-13 21:21:26 +00:00