diff options
author | Chia-I Wu <[email protected]> | 2014-09-24 12:27:23 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2014-09-26 21:15:55 +0800 |
commit | b6443ae969f613458635f043f322ba362e671254 (patch) | |
tree | 06e83bf01ca7334343cabc10aee1b7145aecfc18 /src/gallium/drivers/ilo/ilo_render.c | |
parent | 392890d5de3970f5bee03a3ebce576e63e0a0bbf (diff) |
ilo: rename ilo_3d_pipeline*.[ch] to ilo_render*.[ch]
They are used to build render engine commands, which can be more than 3D.
Signed-off-by: Chia-I Wu <[email protected]>
Diffstat (limited to 'src/gallium/drivers/ilo/ilo_render.c')
-rw-r--r-- | src/gallium/drivers/ilo/ilo_render.c | 163 |
1 files changed, 163 insertions, 0 deletions
diff --git a/src/gallium/drivers/ilo/ilo_render.c b/src/gallium/drivers/ilo/ilo_render.c new file mode 100644 index 00000000000..2893a4f2b93 --- /dev/null +++ b/src/gallium/drivers/ilo/ilo_render.c @@ -0,0 +1,163 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2013 LunarG, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu <[email protected]> + */ + +#include "intel_winsys.h" + +#include "ilo_builder.h" +#include "ilo_render_gen.h" +#include "ilo_render_gen7.h" +#include "ilo_render.h" + +/* in U0.4 */ +struct sample_position { + uint8_t x, y; +}; + +/* \see gen6_get_sample_position() */ +static const struct sample_position sample_position_1x[1] = { + { 8, 8 }, +}; + +static const struct sample_position sample_position_4x[4] = { + { 6, 2 }, /* distance from the center is sqrt(40) */ + { 14, 6 }, /* distance from the center is sqrt(40) */ + { 2, 10 }, /* distance from the center is sqrt(40) */ + { 10, 14 }, /* distance from the center is sqrt(40) */ +}; + +static const struct sample_position sample_position_8x[8] = { + { 7, 9 }, /* distance from the center is sqrt(2) */ + { 9, 13 }, /* distance from the center is sqrt(26) */ + { 11, 3 }, /* distance from the center is sqrt(34) */ + { 13, 11 }, /* distance from the center is sqrt(34) */ + { 1, 7 }, /* distance from the center is sqrt(50) */ + { 5, 1 }, /* distance from the center is sqrt(58) */ + { 15, 5 }, /* distance from the center is sqrt(58) */ + { 3, 15 }, /* distance from the center is sqrt(74) */ +}; + +struct ilo_3d_pipeline * +ilo_3d_pipeline_create(struct ilo_builder *builder) +{ + struct ilo_3d_pipeline *p; + int i; + + p = CALLOC_STRUCT(ilo_3d_pipeline); + if (!p) + return NULL; + + p->dev = builder->dev; + p->builder = builder; + + switch (ilo_dev_gen(p->dev)) { + case ILO_GEN(6): + ilo_3d_pipeline_init_gen6(p); + break; + case ILO_GEN(7): + case ILO_GEN(7.5): + ilo_3d_pipeline_init_gen7(p); + break; + default: + assert(!"unsupported GEN"); + FREE(p); + return NULL; + break; + } + + p->invalidate_flags = ILO_3D_PIPELINE_INVALIDATE_ALL; + + p->workaround_bo = intel_winsys_alloc_buffer(builder->winsys, + "PIPE_CONTROL workaround", 4096, false); + if (!p->workaround_bo) { + ilo_warn("failed to allocate PIPE_CONTROL workaround bo\n"); + FREE(p); + return NULL; + } + + p->packed_sample_position_1x = + sample_position_1x[0].x << 4 | + sample_position_1x[0].y; + + /* pack into dwords */ + for (i = 0; i < 4; i++) { + p->packed_sample_position_4x |= + sample_position_4x[i].x << (8 * i + 4) | + sample_position_4x[i].y << (8 * i); + + p->packed_sample_position_8x[0] |= + sample_position_8x[i].x << (8 * i + 4) | + sample_position_8x[i].y << (8 * i); + + p->packed_sample_position_8x[1] |= + sample_position_8x[4 + i].x << (8 * i + 4) | + sample_position_8x[4 + i].y << (8 * i); + } + + return p; +} + +void +ilo_3d_pipeline_destroy(struct ilo_3d_pipeline *p) +{ + if (p->workaround_bo) + intel_bo_unreference(p->workaround_bo); + + FREE(p); +} + +void +ilo_3d_pipeline_get_sample_position(struct ilo_3d_pipeline *p, + unsigned sample_count, + unsigned sample_index, + float *x, float *y) +{ + const struct sample_position *pos; + + switch (sample_count) { + case 1: + assert(sample_index < Elements(sample_position_1x)); + pos = sample_position_1x; + break; + case 4: + assert(sample_index < Elements(sample_position_4x)); + pos = sample_position_4x; + break; + case 8: + assert(sample_index < Elements(sample_position_8x)); + pos = sample_position_8x; + break; + default: + assert(!"unknown sample count"); + *x = 0.5f; + *y = 0.5f; + return; + break; + } + + *x = (float) pos[sample_index].x / 16.0f; + *y = (float) pos[sample_index].y / 16.0f; +} |