When a texture is bound in its original form then the swizzle states and
the sRGB state were updated and if a texture view of this texture was bound
later it was assumed that the state is already submitted. However, it seems
that a texture view has its own, separate state that must be set separately,
so keep track of it on a per-view basis.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Query the number of supported samples and the sample position and
store these to the caps.v2 structure. We support only up to 16 samples.
This implementation requires a GL host backend.
v2: - glTexImage2Dmultisample is not available on a gles 3.1 host
and trying to call it crashed qemu (Jakob Bornecrantz)
Use glTexStorage2DMultisample instead and delete texture each
round because the texture becomes immutable.
- move call to get sample positions only when caps v2 needs to be
filled.
v3: - rebase against master
- take care of nits (Dave)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
TGSI defines TGSI_SEMANTIC_SAMPLEMASK to be a four-compoent integer
vector, with the x component set to the same value as gl_SampleMask,
and the y, z and w components set to 0.
Fixes the following failures:
dEQP-GLES31.functional.shaders.sample_variables.sample_mask_in.bit_count_per_pixel.multisample_texture_{1,2,4,8,16}
dEQP-GLES31.functional.shaders.sample_variables.sample_mask_in.bit_count_per_pixel.singlesample_rbo
dEQP-GLES31.functional.shaders.sample_variables.sample_mask_in.bit_count_per_pixel.multisample_rbo_{1,2,4,8,16}
dEQP-GLES31.functional.shaders.sample_variables.sample_mask_in.bit_count_per_sample.singlesample_texture
dEQP-GLES31.functional.shaders.sample_variables.sample_mask_in.bit_count_per_sample.multisample_texture_{1,2,4,8,16}
dEQP-GLES31.functional.shaders.sample_variables.sample_mask_in.bit_count_per_sample.multisample_rbo_{1,2,4,8,16}
dEQP-GLES31.functional.shaders.sample_variables.sample_mask_in.bit_count_per_two_samples.singlesample_texture
dEQP-GLES31.functional.shaders.sample_variables.sample_mask_in.bit_count_per_two_samples.multisample_texture_{1,2}
dEQP-GLES31.functional.shaders.sample_variables.sample_mask_in.bit_count_per_two_samples.singlesample_rbo
dEQP-GLES31.functional.shaders.sample_variables.sample_mask_in.bit_count_per_two_samples.multisample_rbo_{1,2}
dEQP-GLES31.functional.shaders.sample_variables.sample_mask_in.bits_unique_per_sample.singlesample_texture
dEQP-GLES31.functional.shaders.sample_variables.sample_mask_in.bits_unique_per_sample.multisample_texture_{1,2,4,8,16}
dEQP-GLES31.functional.shaders.sample_variables.sample_mask_in.bits_unique_per_two_samples.singlesample_texture
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.discard_half_per_pixel.default_framebuffer
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.discard_half_per_pixel.singlesample_texture
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.discard_half_per_pixel.multisample_texture_{1,2,4,8,16}
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.discard_half_per_pixel.singlesample_rbo
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.discard_half_per_pixel.multisample_rbo_{1,2,4,8,16}
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.discard_half_per_sample.default_framebuffer
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.discard_half_per_sample.singlesample_texture
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.discard_half_per_sample.multisample_texture_{1,2,4,8,16}
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.discard_half_per_sample.singlesample_rbo
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.discard_half_per_sample.multisample_rbo_{1,2,4,8,16}
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.discard_half_per_two_samples.default_framebuffer
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.discard_half_per_two_samples.singlesample_texture
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.discard_half_per_two_samples.multisample_texture_{1,2,4,8,16}
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.discard_half_per_two_samples.singlesample_rbo
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.discard_half_per_two_samples.multisample_rbo_{1,2,4,8,16}
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.inverse_per_pixel.default_framebuffer
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.inverse_per_pixel.singlesample_texture
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.inverse_per_pixel.multisample_texture_{1,2,4,8,16}
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.inverse_per_pixel.singlesample_rbo
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.inverse_per_pixel.multisample_rbo_{1,2,4,8,16}
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.inverse_per_sample.default_framebuffer
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.inverse_per_sample.singlesample_texture
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.inverse_per_sample.multisample_texture_{1,2,4,8,16}
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.inverse_per_sample.singlesample_rbo
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.inverse_per_sample.multisample_rbo_{1,2,4,8,16}
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.inverse_per_two_samples.default_framebuffer
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.inverse_per_two_samples.singlesample_texture
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.inverse_per_two_samples.multisample_texture_{1,2,4,8,16}
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.inverse_per_two_samples.singlesample_rbo
dEQP-GLES31.functional.shaders.sample_variables.sample_mask.inverse_per_two_samples.multisample_rbo_{1,2,4,8,16}
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
In 0ea74890db, I had a typo that
made GL_ARB_gpu_shader5 being injected into vertex-shaders that
doesn't need them.
This is obviously a big problem when running on for instance GLES
2.0, where this extension isn't supported. So let's fix this.
Tested-by: Jakob Bornecrantz <jakob@collabora.com>
Reviewed-by: Jakob Bornecrantz <jakob@collabora.com>
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
This just moves the code to a function, it doesn't change any
of the expected code. It should make it easier to spot fixes.
Reviewed-by: Elie Tournier <elie.tournier@collabora.com>
If a shader uses TGSI_INTERPOLATE_LOC_SAMPLE, we need to emit
the "sample"-keyword for the input-variable in the fragment
shader.
Since the "sampler"-keyword is a GLSL 4.00 feature, this
requires us to enable GL_ARB_gpu_shader5. Unfortunately, opting
in carefully on this is a bit trickier than for most other
extensions, because we patch up vertex, geometry or tesselation
evaluation shader outputs to match the fragment shader inputs.
Since the previous patch adds padding for the require-statement
directly after the #version string, we can just overwrite that
padding with the require statement.
This fixes the following tests:
dEQP-GLES31.functional.shaders.multisample_interpolation.sample_qualifier.multisample_texture_1
dEQP-GLES31.functional.shaders.multisample_interpolation.sample_qualifier.multisample_texture_2
dEQP-GLES31.functional.shaders.multisample_interpolation.sample_qualifier.multisample_texture_4
dEQP-GLES31.functional.shaders.multisample_interpolation.sample_qualifier.multisample_texture_8
dEQP-GLES31.functional.shaders.multisample_interpolation.sample_qualifier.multisample_texture_16
dEQP-GLES31.functional.shaders.multisample_interpolation.sample_qualifier.multisample_rbo_1
dEQP-GLES31.functional.shaders.multisample_interpolation.sample_qualifier.multisample_rbo_2
dEQP-GLES31.functional.shaders.multisample_interpolation.sample_qualifier.multisample_rbo_4
dEQP-GLES31.functional.shaders.multisample_interpolation.sample_qualifier.multisample_rbo_8
dEQP-GLES31.functional.shaders.multisample_interpolation.sample_qualifier.multisample_rbo_16
dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_sample.at_sample_id.multisample_texture_1
dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_sample.at_sample_id.multisample_texture_2
dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_sample.at_sample_id.multisample_texture_4
dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_sample.at_sample_id.multisample_texture_8
dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_sample.at_sample_id.multisample_texture_16
dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_sample.at_sample_id.multisample_rbo_1
dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_sample.at_sample_id.multisample_rbo_2
dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_sample.at_sample_id.multisample_rbo_4
dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_sample.at_sample_id.multisample_rbo_8
dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_sample.at_sample_id.multisample_rbo_16
dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_offset.at_sample_position.multisample_texture_1
dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_offset.at_sample_position.multisample_texture_2
dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_offset.at_sample_position.multisample_texture_4
dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_offset.at_sample_position.multisample_texture_8
dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_offset.at_sample_position.multisample_texture_16
dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_offset.at_sample_position.multisample_rbo_1
dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_offset.at_sample_position.multisample_rbo_2
dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_offset.at_sample_position.multisample_rbo_4
dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_offset.at_sample_position.multisample_rbo_8
dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_offset.at_sample_position.multisample_rbo_16
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
The following patch will need enough padding to inject a line like
this into the start of the shader for vertex, geometry and
tesselation evaluation shaders:
So, let's add some appropriately sized space-padding that we can
search for and replace later.
Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
[airlied: rebased back to master]
Reviewed-by: Dave Airlie <airlied@redhat.com>
For multisample textures glTexStorage*DMultisample was only used on GLES
and not when the GL host provided it. Texture views need the texture to be
immutable and this is achieved by allocating them using glTexStorage.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
I've come up with a workaround on the mesa side that should be
backwards compatible with old vtests and vice-versa.
It involves sending both caps 2 and 1 queries back to back,
and taking the first response an indication of what to expect,
v1.1: Check max_size is > 0 before mallocing
Reviewed-by: Jakob Bornecrantz <jakob@collabora.com>
This adds the renderer support for exposing texture views.
The change adds support to sampler views and surfaces for the backing
object to be a separately allocated textureview instead of the actual
resource. It also adds support for parsing the updated packet where
we put the sampler view target in the top 8 bits of the format,
which should be safe as up until now it's always 0.
This doesn't do the final enable of the extension, but it will
cause us to use views in a few places we didn't before so could have
some other side effects
v2: check for buffers on surface creation, reword comment
to better explain if statement.
v3: fix logic bug (Gert). This uncovered a wierd corner case, possibly
due to how the state tracker allocates textures, but it tries to create
a surface with more layers than there are, I think it then reallocate
the whole texture object in the guest and it works out in the end,
this adds check to catch this, and to avoid creating a texture view
in that case.
v4: realise the problem with v3 was 3D textures and use
util_max_layer to fix the logic properly.
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
OpenGL defaults GL_TEXTURE_MIN_FILTER=GL_NEAREST_MIPMAP_LINEAR and
GL_TEXTURE_MAX_LEVEL=1000, and expects all these mip-map levels to be
defined. With glTexStorage this is set apropriately, but when the mip-map
levels are initialiazed manually, then the GL_TEXTURE_MAX_LEVEL must be set.
Tested-by: Jakob Bornecrantz <jakob@collabora.com>
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
This just makes the two functions look a lot more like each other,
since for texture views I have to add some more code to them.
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
I want to change the incoming format to use some bits for texture
view support, so this is precursor to avoid causing problems.
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
When calling glGetnTexImage, glGetnCompressedTexImage, or
glCompressedTexSubImage*D and the data pointer is updated with the
per-slice offset but as bufSize value the full length of the
buffer was given, which can result in a crash of qemu when the buffer
size was not evaluated correctly.
Vor cubemaps instead of passing the size of the whole buffer pass the
size of the slice to make sure that glGetnTexImage doesn't write to
unallocated memory.
v2: Correct handling for 3D textures that are read as one big chunk
vs. cubemaps that are read slice-by-slice (Gurchetan Singh)
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
For rgb8 and rgb16 textures the element size is 3 and 6 respectively,
and the packing must correspond to the component size (1 and 2).
Fixes:
dEQP-GLES3.functional.texture.specification.basic_teximage3d.rgb16i_3d
dEQP-GLES3.functional.texture.specification.basic_teximage3d.rgb16ui_3d
dEQP-GLES3.functional.texture.specification.basic_teximage3d.rgb8i_3d
dEQP-GLES3.functional.texture.specification.basic_teximage3d.rgb8ui_3d
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
In the copy fallback, when a texture can not be rendered, the data that resides
in the backing iovec needs to be used. For the non-zero levels of mip-map textures
the data is located at an offset. This patch adds storing this offset and using it
when data is read from the backing iovec and updating the dst iov. We limit the
mip-map levels for which this is done to 1-17, which is enough to cover
32kx32k textures. The patch also fixes the stride when accessing mip-map levels.
Fixes:
dEQP-GLES3.functional.texture.specification.teximage3d_depth.depth_component24_2d_array
dEQP-GLES3.functional.texture.specification.texsubimage3d_depth.depth_component32f_2d_array
dEQP-GLES3.functional.texture.specification.texsubimage3d_depth.depth_component24_2d_array
dEQP-GLES3.functional.texture.specification.texsubimage3d_depth.depth_component16_2d_array
dEQP-GLES3.functional.texture.specification.texsubimage3d_depth.depth32f_stencil8_2d_array
dEQP-GLES3.functional.texture.specification.texsubimage3d_depth.depth24_stencil8_2d_array
v2: * rebase and remove unused variables
* also correct offset when writing to the destination backing iovec
v3: * follow mesa/virgl notation and range for storing the mip-map offsets
Suggested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
Since the code path emmiting these warnings is no longer used, remove
them and, because with this removal the ctx parameter is now unused,
remove it as well.
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
GLES doesn't have glGetTexImage, so we rely on the assumption that a
resource's backing iovec is always in sync with the texture data if it
isn't renderable.
Fixes on GLES host:
dEQP-GLES3.functional.texture.shadow.*
dEQP-GLES3.functional.texture.wrap.etc2_*.
dEQP-GLES3.functional.texture.units.*
v2: * Special-case VIRGL_FORMAT_Z24X8_UNORM (Gert Wollny)
v3: * Use IOV backing store as data source only on GLES
* Keep backing store only up to date only on GLES
(both Gurchetan Singh)
* copy the backing store data before it is corrected for the Z24X8
format upload
* remove test whether the src surface is renderable, because at this
point it is only relevant whether glGetTexImage is available (i.e.
whether we are on a GLES host)
* Reword commit message
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
Allow the caller to provide a pre-opened DRM file descriptor, to be
used by the EGL context.
Bump callback interface version for compatibility.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Setting the sampler parameter GL_TEXTURE_CUBE_MAP_SEAMLESS in GLES generates a GL_INVALID_ENUM error.
This patch completes the previously committed patch 241b88ac8c.
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This refactors out the shader type code into a separate function,
makes it easier to add compute support later.
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
This pulls the per shader type code out into a separate function.
This is prep work for adding compute shaders.
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
This just pulls in a bunch of TGSI changes from upstream
that make adding GLES3.1 features easier.
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
[airlied: I split this bit out - bisections are a lot easier]
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reason: the second parameter in glBufferSubData() is the offset,
but in vrend_read_from_iovec_cb() function in iov.c, the "count"
is passed to it causing to possibly write beyond the buffer boundary
(or at wrong offset).
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
[airlied: I split this bit out - bisections are a lot easier]
Reviewed-by: Dave Airlie <airlied@redhat.com>
[airlied: pushed the get up a bit higher to make it cleaner]
Reviewed-by: Jakob Bornecrantz <jakob@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
v2: With epoxy GL/gl.h is not directly included (Dave Airlie).
Instead move the include of epoxy/gl.h from vrend_renderer.c to
vrend_renderer.h
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Allow resources created externally (eg gbm created buffers as
dma bufs) to be used. As an example, crosvm
(https://chromium.googlesource.com/chromiumos/platform/crosvm/)
will intercept resource creation to use minigbm to allocate
buffers that its compositor is able to properly handle since it
only supports compositing with buffers allocated via minigbm.
This patch allows direct rendering to those buffers without
requiring an extra copy.
v2: Handle missing extension better.
v3: Update commit message with more details on usage.
Signed-off-by: David Riley <davidriley@chromium.org>
Reviewed-by: Dave Airlie <airlied@redhat.com>
virgl_renderer_resource_get_info() doesn't return the underlying image
stride. eglExportDMABUFImageMESA() does. This fixes imports failing
due to a stride mismatch under certain resolutions. (note that qemu
uses its own export methods, perhaps because Gerd noticed the problem
with virgl egl export functions)
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
On GLES a multi-sample FBO region can only be blit to an non multi-sample
region if the source and the target rectangle are the same. The fallback
using GL and shaders doesn't work if a stencil buffer is involved, because
writing to a stencil buffer from a shader is usually not supported (i.e.
the extension ARB_shader_stencil_export is not available).
Implement a workaround for this case and also the case when the depth
buffer is involved by first blitting the complete multi-sample FBO to an
intermediate, non multi-sample FBO, and apply the region blit to the
actual target FBO afterwards.
Fixes:
dEQP-GLES3.functional.fbo.invalidate.sub.unbind_blit_msaa_color
dEQP-GLES3.functional.fbo.invalidate.sub.unbind_blit_msaa_depth
dEQP-GLES3.functional.fbo.invalidate.sub.unbind_blit_msaa_stencil
dEQP-GLES3.functional.fbo.invalidate.whole.unbind_blit_msaa_color
dEQP-GLES3.functional.fbo.invalidate.whole.unbind_blit_msaa_depth
dEQP-GLES3.functional.fbo.invalidate.whole.unbind_blit_msaa_stencil
v2: * Replace allocation via the formerly extracted resource allocation
funtion with allocating the texture via the newly extracted methods
to copy the texture parameters and allocate the texture.
* in the intermediate blit use the minified size that corresonds
to the layer to be copied
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Tested-by: Jakob Bornecrantz <jakob@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Two functions are extracted from vrend_renderer_resource_create to
make it possible to allocate a texture resource without adding too much
code duplication:
vrend_renderer_resource_copy_args:
copies all required arguments from the args struct into the
already allocated resource
vrend_renderer_resource_allocate_texture:
Allocate a texture using the parameters in the given resource struct
v2: * instead of extracting the complete allocation also including buffers,
only extract the parts that copy the parameters and allocate the texture
* use latest upstream that also includes texture storage objects
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Tested-by: Jakob Bornecrantz <jakob@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
This also exposes patches as a primitive type
v2: enable patch varyings
v3: update patch varyings value from GL API.
Tested-by: Elie Tournier <elie.tournier@collabora.com>
Reviewed-by: Elie Tournier <elie.tournier@collabora.com>
Tested-by: Jakob Bornecrantz <jakob@collabora.com>