Dave Airlie | eb9ad9f | 2016-03-22 07:59:35 +1000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2016 Red Hat. |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * on the rights to use, copy, modify, merge, publish, distribute, sub |
| 8 | * license, and/or sell copies of the Software, and to permit persons to whom |
| 9 | * the Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice (including the next |
| 12 | * paragraph) shall be included in all copies or substantial portions of the |
| 13 | * Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, |
| 19 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 20 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 21 | * USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 22 | */ |
| 23 | |
| 24 | #include "sp_context.h" |
| 25 | #include "sp_state.h" |
| 26 | #include "sp_image.h" |
| 27 | |
| 28 | static void softpipe_set_shader_images(struct pipe_context *pipe, |
| 29 | unsigned shader, |
| 30 | unsigned start, |
| 31 | unsigned num, |
| 32 | struct pipe_image_view *images) |
| 33 | { |
| 34 | struct softpipe_context *softpipe = softpipe_context(pipe); |
| 35 | unsigned i; |
| 36 | assert(shader < PIPE_SHADER_TYPES); |
| 37 | assert(start + num <= Elements(softpipe->sampler_views[shader])); |
| 38 | |
| 39 | /* set the new images */ |
| 40 | for (i = 0; i < num; i++) { |
| 41 | int idx = start + i; |
| 42 | |
| 43 | if (images) { |
| 44 | pipe_resource_reference(&softpipe->tgsi.image[shader]->sp_iview[idx].resource, images[i].resource); |
| 45 | softpipe->tgsi.image[shader]->sp_iview[idx] = images[i]; |
| 46 | } |
| 47 | else { |
| 48 | pipe_resource_reference(&softpipe->tgsi.image[shader]->sp_iview[idx].resource, NULL); |
| 49 | memset(&softpipe->tgsi.image[shader]->sp_iview[idx], 0, sizeof(struct pipe_image_view)); |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | void softpipe_init_image_funcs(struct pipe_context *pipe) |
| 55 | { |
| 56 | pipe->set_shader_images = softpipe_set_shader_images; |
| 57 | } |