...
 
Commits (177)
...@@ -132,6 +132,7 @@ with_gallium_r300 = false ...@@ -132,6 +132,7 @@ with_gallium_r300 = false
with_gallium_r600 = false with_gallium_r600 = false
with_gallium_nouveau = false with_gallium_nouveau = false
with_gallium_freedreno = false with_gallium_freedreno = false
with_gallium_panfrost = false
with_gallium_softpipe = false with_gallium_softpipe = false
with_gallium_vc4 = false with_gallium_vc4 = false
with_gallium_vc5 = false with_gallium_vc5 = false
...@@ -149,7 +150,7 @@ if _drivers == 'auto' ...@@ -149,7 +150,7 @@ if _drivers == 'auto'
if ['x86', 'x86_64'].contains(host_machine.cpu_family()) if ['x86', 'x86_64'].contains(host_machine.cpu_family())
_drivers = 'r300,r600,radeonsi,nouveau,virgl,svga,swrast' _drivers = 'r300,r600,radeonsi,nouveau,virgl,svga,swrast'
elif ['arm', 'aarch64'].contains(host_machine.cpu_family()) elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
_drivers = 'pl111,vc4,vc5,freedreno,etnaviv,imx,nouveau,tegra,virgl,svga,swrast' _drivers = 'pl111,vc4,vc5,panfrost,freedreno,etnaviv,imx,nouveau,tegra,virgl,svga,swrast'
else else
error('Unknown architecture. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.') error('Unknown architecture. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.')
endif endif
...@@ -167,6 +168,7 @@ if _drivers != '' ...@@ -167,6 +168,7 @@ if _drivers != ''
with_gallium_r600 = _split.contains('r600') with_gallium_r600 = _split.contains('r600')
with_gallium_nouveau = _split.contains('nouveau') with_gallium_nouveau = _split.contains('nouveau')
with_gallium_freedreno = _split.contains('freedreno') with_gallium_freedreno = _split.contains('freedreno')
with_gallium_panfrost = _split.contains('panfrost')
with_gallium_softpipe = _split.contains('swrast') with_gallium_softpipe = _split.contains('swrast')
with_gallium_vc4 = _split.contains('vc4') with_gallium_vc4 = _split.contains('vc4')
with_gallium_vc5 = _split.contains('vc5') with_gallium_vc5 = _split.contains('vc5')
......
...@@ -1888,6 +1888,7 @@ typedef struct nir_shader_compiler_options { ...@@ -1888,6 +1888,7 @@ typedef struct nir_shader_compiler_options {
bool lower_extract_word; bool lower_extract_word;
bool lower_all_io_to_temps; bool lower_all_io_to_temps;
bool lower_fsinpi;
/** /**
* Does the driver support real 32-bit integers? (Otherwise, integers * Does the driver support real 32-bit integers? (Otherwise, integers
......
...@@ -214,6 +214,8 @@ unop("fquantize2f16", tfloat, "(fabs(src0) < ldexpf(1.0, -14)) ? copysignf(0.0f, ...@@ -214,6 +214,8 @@ unop("fquantize2f16", tfloat, "(fabs(src0) < ldexpf(1.0, -14)) ? copysignf(0.0f,
unop("fsin", tfloat, "bit_size == 64 ? sin(src0) : sinf(src0)") unop("fsin", tfloat, "bit_size == 64 ? sin(src0) : sinf(src0)")
unop("fcos", tfloat, "bit_size == 64 ? cos(src0) : cosf(src0)") unop("fcos", tfloat, "bit_size == 64 ? cos(src0) : cosf(src0)")
unop("fsinpi", tfloat, "bit_size == 64 ? sin(src0 / 3.14159) : sinf(src0 / 3.14159)")
unop("fcospi", tfloat, "bit_size == 64 ? cos(src0 / 3.14159) : cosf(src0 / 3.14159)")
# Partial derivatives. # Partial derivatives.
......
...@@ -562,6 +562,9 @@ optimizations = [ ...@@ -562,6 +562,9 @@ optimizations = [
('extract_i8', 'v', 3))), ('extract_i8', 'v', 3))),
127.0))), 127.0))),
'options->lower_unpack_snorm_4x8'), 'options->lower_unpack_snorm_4x8'),
(('fsin', a), ('fsinpi', ('fdiv', a, 3.14159)), 'options->lower_fsinpi'),
(('fcos', a), ('fcospi', ('fdiv', a, 3.14159)), 'options->lower_fsinpi'),
] ]
invert = {'feq': 'fne', 'fne': 'feq', 'fge': 'flt', 'flt': 'fge' } invert = {'feq': 'fne', 'fne': 'feq', 'fge': 'flt', 'flt': 'fge' }
......
midgard_compiler = executable(
'midgard_compiler',
'midgard/midgard_cmdline.c',
include_directories : [inc_common, inc_src, inc_include, inc_gallium, inc_gallium_aux, include_directories('midgard')],
dependencies : [
dep_thread,
idep_nir
],
link_with : [
libgallium,
libglsl_standalone,
libmesa_util
],
build_by_default : true
)
/* Author(s):
* Connor Abbott
* Alyssa Rosenzweig
*
* Copyright (c) 2013 Connor Abbott (connor@abbott.cx)
* Copyright (c) 2018 Alyssa Rosenzweig (alyssa@rosenzweig.io)
*
* 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.
*/
/* midgard.h - definitions for the Midgard shader architecture */
typedef unsigned midgard_word_type;
typedef enum
{
midgard_alu_vmul,
midgard_alu_sadd,
midgard_alu_smul,
midgard_alu_vadd,
midgard_alu_lut
} midgard_alu_e;
/*
* ALU words
*/
typedef enum
{
midgard_alu_op_fadd = 0x10,
midgard_alu_op_fmul = 0x14,
midgard_alu_op_fmin = 0x28,
midgard_alu_op_fmax = 0x2C,
midgard_alu_op_fmov = 0x30,
midgard_alu_op_ffloor = 0x36,
midgard_alu_op_fceil = 0x37,
midgard_alu_op_fdot3 = 0x3C,
midgard_alu_op_fdot3r = 0x3D,
midgard_alu_op_fdot4 = 0x3E,
midgard_alu_op_freduce = 0x3F,
midgard_alu_op_iadd = 0x40,
midgard_alu_op_isub = 0x46,
midgard_alu_op_imul = 0x58,
midgard_alu_op_imov = 0x7B,
midgard_alu_op_feq = 0x80,
midgard_alu_op_fne = 0x81,
midgard_alu_op_flt = 0x82,
midgard_alu_op_fle = 0x83,
midgard_alu_op_f2i = 0x99,
midgard_alu_op_ieq = 0xA0,
midgard_alu_op_ine = 0xA1,
midgard_alu_op_ilt = 0xA4,
midgard_alu_op_ile = 0xA5,
midgard_alu_op_ball = 0xA9,
midgard_alu_op_bany = 0xB1,
midgard_alu_op_i2f = 0xB8,
midgard_alu_op_csel = 0xC5,
midgard_alu_op_fatan_pt2 = 0xE8,
midgard_alu_op_frcp = 0xF0,
midgard_alu_op_frsqrt = 0xF2,
midgard_alu_op_fsqrt = 0xF3,
midgard_alu_op_fexp2 = 0xF4,
midgard_alu_op_flog2 = 0xF5,
midgard_alu_op_fsin = 0xF6,
midgard_alu_op_fcos = 0xF7,
midgard_alu_op_fatan_pt1 = 0xF9,
} midgard_alu_op_e;
typedef enum
{
midgard_outmod_none = 0,
midgard_outmod_pos = 1,
midgard_outmod_int = 2,
midgard_outmod_sat = 3
} midgard_outmod_e;
typedef enum
{
midgard_reg_mode_half = 1,
midgard_reg_mode_full = 2
} midgard_reg_mode_e;
typedef enum
{
midgard_dest_override_lower = 0,
midgard_dest_override_upper = 1,
midgard_dest_override_none = 2
} midgard_dest_override_e;
typedef struct
__attribute__((__packed__))
{
bool abs : 1;
bool negate : 1;
/* replicate lower half if dest = half, or low/high half selection if
* dest = full
*/
bool rep_low : 1;
bool rep_high : 1; /* unused if dest = full */
bool half : 1; /* only matters if dest = full */
unsigned swizzle : 8;
} midgard_vector_alu_src_t;
typedef struct
__attribute__((__packed__))
{
midgard_alu_op_e op : 8;
midgard_reg_mode_e reg_mode : 2;
unsigned src1 : 13;
unsigned src2 : 13;
midgard_dest_override_e dest_override : 2;
midgard_outmod_e outmod : 2;
unsigned mask : 8;
} midgard_vector_alu_t;
typedef struct
__attribute__((__packed__))
{
bool abs : 1;
bool negate : 1;
bool full : 1; /* 0 = half, 1 = full */
unsigned component : 3;
} midgard_scalar_alu_src_t;
typedef struct
__attribute__((__packed__))
{
midgard_alu_op_e op : 8;
unsigned src1 : 6;
unsigned src2 : 11;
unsigned unknown : 1;
midgard_outmod_e outmod : 2;
bool output_full : 1;
unsigned output_component : 3;
} midgard_scalar_alu_t;
/* ALU control words are single bit fields with a lot of space */
#define ALU_ENAB_VEC_MUL (1 << 17)
#define ALU_ENAB_SCAL_ADD (1 << 19)
#define ALU_ENAB_VEC_ADD (1 << 21)
#define ALU_ENAB_SCAL_MUL (1 << 23)
#define ALU_ENAB_VEC_LUT (1 << 25)
#define ALU_ENAB_BR_COMPACT (1 << 26)
#define ALU_ENAB_BRANCH (1 << 27)
/* Vector-independant shorthands for the above; these numbers are arbitrary and
* not from the ISA. Convert to the above with unit_enum_to_midgard */
#define UNIT_MUL 0
#define UNIT_ADD 1
#define UNIT_LUT 2
/* ALU register fields are weird because of inline constants */
typedef struct
__attribute__((__packed__))
{
unsigned input1_reg : 5;
unsigned input2_reg : 5;
unsigned output_reg : 5;
unsigned inline_2 : 1;
} alu_register_word;
typedef struct
__attribute__((__packed__))
{
unsigned src1_reg : 5;
unsigned src2_reg : 5;
unsigned out_reg : 5;
bool src2_imm : 1;
} midgard_reg_info_t;
/* Compact writeouts */
typedef enum
{
midgard_jmp_writeout_op_branch_uncond = 1,
midgard_jmp_writeout_op_branch_cond = 2,
midgard_jmp_writeout_op_writeout = 7,
} midgard_jmp_writeout_op_e;
typedef struct
__attribute__((__packed__))
{
midgard_jmp_writeout_op_e op : 3; /* == branch_uncond */
unsigned dest_tag : 4; /* tag of branch destination */
unsigned unknown : 2;
int offset : 7;
} midgard_branch_uncond_t;
typedef struct
__attribute__((__packed__))
{
midgard_jmp_writeout_op_e op : 3; /* == branch_cond */
unsigned dest_tag : 4; /* tag of branch destination */
int offset : 7;
unsigned cond : 2;
} midgard_branch_cond_t;
/*
* Load/store words
*/
#define OP_IS_STORE(op) (\
op == midgard_op_store_vary_16 || \
op == midgard_op_store_vary_32 \
)
typedef enum
{
midgard_op_ld_st_noop = 0x03,
midgard_op_load_attr_16 = 0x95,
midgard_op_load_attr_32 = 0x94,
midgard_op_load_vary_16 = 0x99,
midgard_op_load_vary_32 = 0x98,
midgard_op_load_uniform_16 = 0xAC,
midgard_op_load_uniform_32 = 0xB0,
midgard_op_store_vary_16 = 0xD5,
midgard_op_store_vary_32 = 0xD4
} midgard_load_store_op_e;
typedef struct
__attribute__((__packed__))
{
midgard_load_store_op_e op : 8;
unsigned reg : 5;
unsigned mask : 4;
unsigned swizzle : 8;
unsigned unknown : 26;
unsigned address : 9;
} midgard_load_store_word_t;
typedef struct
__attribute__((__packed__))
{
uint8_t tag : 8;
uint64_t word1 : 60;
uint64_t word2 : 60;
} midgard_load_store_t;
/* Some defines not found in the disassembler */
/* 4-bit type tags */
#define TAG_TEXTURE_4 0x3
#define TAG_LOAD_STORE_4 0x5
#define TAG_ALU_4 0x8
#define TAG_ALU_8 0x9
#define TAG_ALU_12 0xA
#define TAG_ALU_16 0xB
/* Special register aliases */
#define REGISTER_UNUSED 24
#define REGISTER_CONSTANT 26
#define REGISTER_OFFSET 27
#define REGISTER_VERTEX 27
#define REGISTER_TEXTURE_1 28
#define REGISTER_TEXTURE_2 29
#define REGISTER_SELECT 31
/* SSA helper aliases to mimic the registers. UNUSED_0 encoded as an inline
* constant. UNUSED_1 encoded as REGISTER_UNUSED */
#define SSA_UNUSED_0 0
#define SSA_UNUSED_1 -2
#define SSA_FIXED_SHIFT 24
#define SSA_FIXED_REGISTER(reg) ((1 + reg) << SSA_FIXED_SHIFT)
#define SSA_REG_FROM_FIXED(reg) ((reg >> SSA_FIXED_SHIFT) - 1)
#define SSA_FIXED_MINIMUM SSA_FIXED_REGISTER(0)
/* Should be mapped to REGISTER_VERTEX, eventually */
#define VERTEX_EPILOGUE_BASE 0xDEAD00
/* Swizzle support */
#define SWIZZLE(A, B, C, D) ((D << 6) | (C << 4) | (B << 2) | (A << 0))
#define SWIZZLE_FROM_ARRAY(r) SWIZZLE(r[0], r[1], r[2], r[3])
#define COMPONENT_X 0x0
#define COMPONENT_Y 0x1
#define COMPONENT_Z 0x2
#define COMPONENT_W 0x3
/* Output writing "condition" for the branch (all one's) */
#define COND_FBWRITE 0x3
This diff is collapsed.
# Mesa 3-D graphics library
#
# Copyright (C) 2010-2011 Chia-I Wu <olvaffe@gmail.com>
# Copyright (C) 2010-2011 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.
LOCAL_PATH := $(call my-dir)
# get C_SOURCES
include $(LOCAL_PATH)/Makefile.sources
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(C_SOURCES)
LOCAL_MODULE := libmesa_pipe_softpipe
include $(GALLIUM_COMMON_MK)
include $(BUILD_STATIC_LIBRARY)
ifneq ($(HAVE_GALLIUM_SOFTPIPE),)
GALLIUM_TARGET_DRIVERS += swrast
$(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_sw_dri)
endif
if HAVE_GALLIUM_SOFTPIPE
TARGET_DRIVERS += swrast
TARGET_CPPFLAGS += -DGALLIUM_SOFTPIPE
TARGET_LIB_DEPS += \
$(top_builddir)/src/gallium/drivers/softpipe/libsoftpipe.la
if HAVE_DRISW_KMS
TARGET_DRIVERS += kms_swrast
endif
endif
# Copyright © 2012 Intel Corporation
#
# 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 (including the next
# paragraph) 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.
include Makefile.sources
include $(top_srcdir)/src/gallium/Automake.inc
AM_CFLAGS = \
$(GALLIUM_DRIVER_CFLAGS) \
$(MSVC2013_COMPAT_CFLAGS)
noinst_LTLIBRARIES = libsoftpipe.la
libsoftpipe_la_SOURCES = $(C_SOURCES)
EXTRA_DIST = SConscript meson.build
C_SOURCES := \
sp_buffer.c \
sp_buffer.h \
sp_clear.c \
sp_clear.h \
sp_context.c \
sp_context.h \
sp_compute.c \
sp_draw_arrays.c \
sp_fence.c \
sp_fence.h \
sp_flush.c \
sp_flush.h \
sp_fs_exec.c \
sp_fs.h \
sp_image.c \
sp_image.h \
sp_limits.h \
sp_prim_vbuf.c \
sp_prim_vbuf.h \
sp_public.h \
sp_quad_blend.c \
sp_quad_depth_test.c \
sp_quad_depth_test_tmp.h \
sp_quad_fs.c \
sp_quad.h \
sp_quad_pipe.c \
sp_quad_pipe.h \
sp_quad_stipple.c \
sp_query.c \
sp_query.h \
sp_screen.c \
sp_screen.h \
sp_setup.c \
sp_setup.h \
sp_state_blend.c \
sp_state_clip.c \
sp_state_derived.c \
sp_state_image.c \
sp_state.h \
sp_state_rasterizer.c \
sp_state_sampler.c \
sp_state_shader.c \
sp_state_so.c \
sp_state_surface.c \
sp_state_vertex.c \
sp_surface.c \
sp_surface.h \
sp_tex_sample.c \
sp_tex_sample.h \
sp_tex_tile_cache.c \
sp_tex_tile_cache.h \
sp_texture.c \
sp_texture.h \
sp_tile_cache.c \
sp_tile_cache.h
Import('*')
env = env.Clone()
env.MSVC2013Compat()
softpipe = env.ConvenienceLibrary(
target = 'softpipe',
source = env.ParseSourceList('Makefile.sources', 'C_SOURCES')
)
env.Alias('softpipe', softpipe)
Export('softpipe')
# Copyright © 2017 Intel Corporation
# 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.
files_softpipe = files(
'sp_buffer.c',
'sp_buffer.h',
'sp_clear.c',
'sp_clear.h',
'sp_context.c',
'sp_context.h',
'sp_compute.c',
'sp_draw_arrays.c',
'sp_fence.c',
'sp_fence.h',
'sp_flush.c',
'sp_flush.h',
'sp_fs_exec.c',
'sp_fs.h',
'sp_image.c',
'sp_image.h',
'sp_limits.h',
'sp_prim_vbuf.c',
'sp_prim_vbuf.h',
'sp_public.h',
'sp_quad_blend.c',
'sp_quad_depth_test.c',
'sp_quad_depth_test_tmp.h',
'sp_quad_fs.c',
'sp_quad.h',
'sp_quad_pipe.c',
'sp_quad_pipe.h',
'sp_quad_stipple.c',
'sp_query.c',
'sp_query.h',
'sp_screen.c',
'sp_screen.h',
'sp_setup.c',
'sp_setup.h',
'sp_state_blend.c',
'sp_state_clip.c',
'sp_state_derived.c',
'sp_state_image.c',
'sp_state.h',
'sp_state_rasterizer.c',
'sp_state_sampler.c',
'sp_state_shader.c',
'sp_state_so.c',
'sp_state_surface.c',
'sp_state_vertex.c',
'sp_surface.c',
'sp_surface.h',
'sp_tex_sample.c',
'sp_tex_sample.h',
'sp_tex_tile_cache.c',
'sp_tex_tile_cache.h',
'sp_texture.c',
'sp_texture.h',
'sp_tile_cache.c',
'sp_tile_cache.h',
)
libsoftpipe = static_library(
'softpipe',
files_softpipe,
include_directories : [inc_gallium_aux, inc_gallium, inc_include, inc_src],
c_args : [c_vis_args, c_msvc_compat_args],
)
driver_swrast = declare_dependency(
compile_args : '-DGALLIUM_SOFTPIPE',
link_with : libsoftpipe
)
This diff is collapsed.
/*
* Copyright 2016 Red Hat.
*
* 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
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, 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 (including the next
* paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
* THE AUTHOR(S) AND/OR THEIR SUPPLIERS 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.
*/
#ifndef SP_BUFFER_H
#define SP_BUFFER_H
#include "tgsi/tgsi_exec.h"
struct sp_tgsi_buffer
{
struct tgsi_buffer base;
struct pipe_shader_buffer sp_bview[PIPE_MAX_SHADER_BUFFERS];
};
struct sp_tgsi_buffer *
sp_create_tgsi_buffer(void);
#endif
/**************************************************************************
*
* Copyright 2007 VMware, Inc.
* All Rights Reserved.
* Copyright 2009 VMware, Inc. All Rights Reserved.
*
* 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, sub license, 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 (including the
* next paragraph) 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 NON-INFRINGEMENT.
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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.
*
**************************************************************************/
/* Author:
* Brian Paul
* Michel Dänzer
*/
#include "pipe/p_defines.h"
#include "util/u_pack_color.h"
#include "util/u_surface.h"
#include "sp_clear.h"
#include "sp_context.h"
#include "sp_query.h"
#include "sp_tile_cache.h"
/**
* Clear the given buffers to the specified values.
* No masking, no scissor (clear entire buffer).
*/
void
softpipe_clear(struct pipe_context *pipe, unsigned buffers,
const union pipe_color_union *color,
double depth, unsigned stencil)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
struct pipe_surface *zsbuf = softpipe->framebuffer.zsbuf;
unsigned zs_buffers = buffers & PIPE_CLEAR_DEPTHSTENCIL;
uint64_t cv;
uint i;
if (softpipe->no_rast)
return;
if (!softpipe_check_render_cond(softpipe))
return;
#if 0
softpipe_update_derived(softpipe, PIPE_PRIM_TRIANGLES); /* not needed?? */
#endif
if (buffers & PIPE_CLEAR_COLOR) {
for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) {
sp_tile_cache_clear(softpipe->cbuf_cache[i], color, 0);
}
}
if (zs_buffers &&
util_format_is_depth_and_stencil(zsbuf->texture->format) &&
zs_buffers != PIPE_CLEAR_DEPTHSTENCIL) {
/* Clearing only depth or stencil in a combined depth-stencil buffer. */
util_clear_depth_stencil(pipe, zsbuf, zs_buffers, depth, stencil,
0, 0, zsbuf->width, zsbuf->height);
}
else if (zs_buffers) {
static const union pipe_color_union zero;
cv = util_pack64_z_stencil(zsbuf->format, depth, stencil);
sp_tile_cache_clear(softpipe->zsbuf_cache, &zero, cv);
}
softpipe->dirty_render_cache = TRUE;
}
/**************************************************************************
*
* Copyright 2007 VMware, Inc.
* All Rights Reserved.
*
* 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, sub license, 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 (including the
* next paragraph) 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 NON-INFRINGEMENT.
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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.
*
**************************************************************************/
/* Author:
* Brian Paul
*/
#ifndef SP_CLEAR_H
#define SP_CLEAR_H
struct pipe_context;
extern void
softpipe_clear(struct pipe_context *pipe, unsigned buffers,
const union pipe_color_union *color,
double depth, unsigned stencil);
#endif /* SP_CLEAR_H */
/*
* Copyright 2016 Red Hat.
*
* 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
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, 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 (including the next
* paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
* THE AUTHOR(S) AND/OR THEIR SUPPLIERS 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.
*/
#include "util/u_inlines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "util/u_pstipple.h"
#include "pipe/p_shader_tokens.h"
#include "draw/draw_context.h"
#include "draw/draw_vertex.h"
#include "sp_context.h"
#include "sp_screen.h"
#include "sp_state.h"
#include "sp_texture.h"
#include "sp_tex_sample.h"
#include "sp_tex_tile_cache.h"
#include "tgsi/tgsi_parse.h"
static void
cs_prepare(const struct sp_compute_shader *cs,
struct tgsi_exec_machine *machine,
int w, int h, int d,
int g_w, int g_h, int g_d,
int b_w, int b_h, int b_d,
struct tgsi_sampler *sampler,
struct tgsi_image *image,
struct tgsi_buffer *buffer )
{
int j;
/*
* Bind tokens/shader to the interpreter's machine state.
*/
tgsi_exec_machine_bind_shader(machine,
cs->tokens,
sampler, image, buffer);
if (machine->SysSemanticToIndex[TGSI_SEMANTIC_THREAD_ID] != -1) {
unsigned i = machine->SysSemanticToIndex[TGSI_SEMANTIC_THREAD_ID];
for (j = 0; j < TGSI_QUAD_SIZE; j++) {
machine->SystemValue[i].xyzw[0].i[j] = w;
machine->SystemValue[i].xyzw[1].i[j] = h;
machine->SystemValue[i].xyzw[2].i[j] = d;
}
}
if (machine->SysSemanticToIndex[TGSI_SEMANTIC_GRID_SIZE] != -1) {
unsigned i = machine->SysSemanticToIndex[TGSI_SEMANTIC_GRID_SIZE];
for (j = 0; j < TGSI_QUAD_SIZE; j++) {
machine->SystemValue[i].xyzw[0].i[j] = g_w;
machine->SystemValue[i].xyzw[1].i[j] = g_h;
machine->SystemValue[i].xyzw[2].i[j] = g_d;
}
}
if (machine->SysSemanticToIndex[TGSI_SEMANTIC_BLOCK_SIZE] != -1) {
unsigned i = machine->SysSemanticToIndex[TGSI_SEMANTIC_BLOCK_SIZE];
for (j = 0; j < TGSI_QUAD_SIZE; j++) {
machine->SystemValue[i].xyzw[0].i[j] = b_w;
machine->SystemValue[i].xyzw[1].i[j] = b_h;
machine->SystemValue[i].xyzw[2].i[j] = b_d;
}
}
}
static bool
cs_run(const struct sp_compute_shader *cs,
int g_w, int g_h, int g_d,
struct tgsi_exec_machine *machine, bool restart)
{
if (!restart) {
if (machine->SysSemanticToIndex[TGSI_SEMANTIC_BLOCK_ID] != -1) {
unsigned i = machine->SysSemanticToIndex[TGSI_SEMANTIC_BLOCK_ID];
int j;
for (j = 0; j < TGSI_QUAD_SIZE; j++) {
machine->SystemValue[i].xyzw[0].i[j] = g_w;
machine->SystemValue[i].xyzw[1].i[j] = g_h;
machine->SystemValue[i].xyzw[2].i[j] = g_d;
}
}
machine->NonHelperMask = (1 << 1) - 1;
}
tgsi_exec_machine_run(machine, restart ? machine->pc : 0);
if (machine->pc != -1)
return true;
return false;
}
static void
run_workgroup(const struct sp_compute_shader *cs,
int g_w, int g_h, int g_d, int num_threads,
struct tgsi_exec_machine **machines)
{
int i;
bool grp_hit_barrier, restart_threads = false;
do {
grp_hit_barrier = false;
for (i = 0; i < num_threads; i++) {
grp_hit_barrier |= cs_run(cs, g_w, g_h, g_d, machines[i], restart_threads);
}
restart_threads = false;
if (grp_hit_barrier) {
grp_hit_barrier = false;
restart_threads = true;
}
} while (restart_threads);
}
static void
cs_delete(const struct sp_compute_shader *cs,
struct tgsi_exec_machine *machine)
{
if (machine->Tokens == cs->tokens) {
tgsi_exec_machine_bind_shader(machine, NULL, NULL, NULL, NULL);
}
}
static void
fill_grid_size(struct pipe_context *context,
const struct pipe_grid_info *info,
uint32_t grid_size[3])
{
struct pipe_transfer *transfer;
uint32_t *params;
if (!info->indirect) {
grid_size[0] = info->grid[0];
grid_size[1] = info->grid[1];
grid_size[2] = info->grid[2];
return;
}
params = pipe_buffer_map_range(context, info->indirect,
info->indirect_offset,
3 * sizeof(uint32_t),
PIPE_TRANSFER_READ,
&transfer);
if (!transfer)
return;
grid_size[0] = params[0];
grid_size[1] = params[1];
grid_size[2] = params[2];
pipe_buffer_unmap(context, transfer);
}
void
softpipe_launch_grid(struct pipe_context *context,
const struct pipe_grid_info *info)
{
struct softpipe_context *softpipe = softpipe_context(context);
struct sp_compute_shader *cs = softpipe->cs;
int num_threads_in_group;
struct tgsi_exec_machine **machines;
int bwidth, bheight, bdepth;
int w, h, d, i;
int g_w, g_h, g_d;
uint32_t grid_size[3] = {0};
void *local_mem = NULL;
softpipe_update_compute_samplers(softpipe);
bwidth = cs->info.properties[TGSI_PROPERTY_CS_FIXED_BLOCK_WIDTH];
bheight = cs->info.properties[TGSI_PROPERTY_CS_FIXED_BLOCK_HEIGHT];
bdepth = cs->info.properties[TGSI_PROPERTY_CS_FIXED_BLOCK_DEPTH];
num_threads_in_group = bwidth * bheight * bdepth;
fill_grid_size(context, info, grid_size);
if (cs->shader.req_local_mem) {
local_mem = CALLOC(1, cs->shader.req_local_mem);
}
machines = CALLOC(sizeof(struct tgsi_exec_machine *), num_threads_in_group);
if (!machines) {
FREE(local_mem);
return;
}
/* initialise machines + GRID_SIZE + THREAD_ID + BLOCK_SIZE */
for (d = 0; d < bdepth; d++) {
for (h = 0; h < bheight; h++) {
for (w = 0; w < bwidth; w++) {
int idx = w + (h * bwidth) + (d * bheight * bwidth);
machines[idx] = tgsi_exec_machine_create(PIPE_SHADER_COMPUTE);
machines[idx]->LocalMem = local_mem;
machines[idx]->LocalMemSize = cs->shader.req_local_mem;
cs_prepare(cs, machines[idx],
w, h, d,
grid_size[0], grid_size[1], grid_size[2],
bwidth, bheight, bdepth,
(struct tgsi_sampler *)softpipe->tgsi.sampler[PIPE_SHADER_COMPUTE],
(struct tgsi_image *)softpipe->tgsi.image[PIPE_SHADER_COMPUTE],
(struct tgsi_buffer *)softpipe->tgsi.buffer[PIPE_SHADER_COMPUTE]);
tgsi_exec_set_constant_buffers(machines[idx], PIPE_MAX_CONSTANT_BUFFERS,
softpipe->mapped_constants[PIPE_SHADER_COMPUTE],
softpipe->const_buffer_size[PIPE_SHADER_COMPUTE]);
}
}
}
for (g_d = 0; g_d < grid_size[2]; g_d++) {
for (g_h = 0; g_h < grid_size[1]; g_h++) {
for (g_w = 0; g_w < grid_size[0]; g_w++) {
run_workgroup(cs, g_w, g_h, g_d, num_threads_in_group, machines);
}
}
}
for (i = 0; i < num_threads_in_group; i++) {
cs_delete(cs, machines[i]);
tgsi_exec_machine_destroy(machines[i]);
}
FREE(local_mem);
FREE(machines);
}
This diff is collapsed.
/**************************************************************************
*
* Copyright 2007 VMware, Inc.
* All Rights Reserved.
*
* 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, sub license, 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 (including the
* next paragraph) 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 NON-INFRINGEMENT.
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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: Keith Whitwell <keithw@vmware.com>
*/
#ifndef SP_CONTEXT_H
#define SP_CONTEXT_H
#include "pipe/p_context.h"
#include "util/u_blitter.h"
#include "draw/draw_vertex.h"
#include "sp_quad_pipe.h"
#include "sp_setup.h"
/** Do polygon stipple in the draw module? */
#define DO_PSTIPPLE_IN_DRAW_MODULE 0
/** Do polygon stipple with the util module? */
#define DO_PSTIPPLE_IN_HELPER_MODULE 1
struct softpipe_vbuf_render;
struct draw_context;
struct draw_stage;
struct softpipe_tile_cache;
struct softpipe_tex_tile_cache;
struct sp_fragment_shader;
struct sp_vertex_shader;
struct sp_velems_state;
struct sp_so_state;
struct softpipe_context {
struct pipe_context pipe; /**< base class */
/** Constant state objects */
struct pipe_blend_state *blend;
struct pipe_sampler_state *samplers[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
struct pipe_depth_stencil_alpha_state *depth_stencil;
struct pipe_rasterizer_state *rasterizer;
struct sp_fragment_shader *fs;
struct sp_fragment_shader_variant *fs_variant;
struct sp_vertex_shader *vs;
struct sp_geometry_shader *gs;
struct sp_velems_state *velems;
struct sp_so_state *so;
struct sp_compute_shader *cs;
/** Other rendering state */
struct pipe_blend_color blend_color;
struct pipe_blend_color blend_color_clamped;
struct pipe_stencil_ref stencil_ref;
struct pipe_clip_state clip;
struct pipe_resource *constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];
struct pipe_framebuffer_state framebuffer;
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissors[PIPE_MAX_VIEWPORTS];
struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS];
struct pipe_image_view images[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_IMAGES];
struct pipe_shader_buffer buffers[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_BUFFERS];
struct pipe_viewport_state viewports[PIPE_MAX_VIEWPORTS];
struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
struct pipe_resource *mapped_vs_tex[PIPE_MAX_SHADER_SAMPLER_VIEWS];
struct pipe_resource *mapped_gs_tex[PIPE_MAX_SHADER_SAMPLER_VIEWS];
struct draw_so_target *so_targets[PIPE_MAX_SO_BUFFERS];
unsigned num_so_targets;
struct pipe_query_data_so_statistics so_stats;
struct pipe_query_data_pipeline_statistics pipeline_statistics;
unsigned active_statistics_queries;
unsigned num_samplers[PIPE_SHADER_TYPES];
unsigned num_sampler_views[PIPE_SHADER_TYPES];
unsigned num_vertex_buffers;
unsigned dirty; /**< Mask of SP_NEW_x flags */
/* Counter for occlusion queries. Note this supports overlapping
* queries.
*/
uint64_t occlusion_count;
unsigned active_query_count;
/** Mapped vertex buffers */
ubyte *mapped_vbuffer[PIPE_MAX_ATTRIBS];
/** Mapped constant buffers */
const void *mapped_constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];
unsigned const_buffer_size[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];
/** Vertex format */
struct sp_setup_info setup_info;
struct vertex_info vertex_info;
/** Which vertex shader output slot contains point size */
int8_t psize_slot;
/** Which vertex shader output slot contains viewport index */
int8_t viewport_index_slot;
/** Which vertex shader output slot contains layer */
int8_t layer_slot;
/** The reduced version of the primitive supplied by the state tracker */
unsigned reduced_api_prim;
/** Derived information about which winding orders to cull */
unsigned cull_mode;
/**
* The reduced primitive after unfilled triangles, wide-line decomposition,
* etc, are taken into account. This is the primitive type that's actually
* rasterized.
*/
unsigned reduced_prim;
/** Derived from scissor and surface bounds: */
struct pipe_scissor_state cliprect[PIPE_MAX_VIEWPORTS];
/** Conditional query object and mode */
struct pipe_query *render_cond_query;
enum pipe_render_cond_flag render_cond_mode;
boolean render_cond_cond;
/** Polygon stipple items */
struct {
struct pipe_resource *texture;
struct pipe_sampler_state *sampler;
struct pipe_sampler_view *sampler_view;
} pstipple;
/** Software quad rendering pipeline */
struct {
struct quad_stage *shade;
struct quad_stage *depth_test;
struct quad_stage *blend;
struct quad_stage *pstipple;
struct quad_stage *first; /**< points to one of the above stages */
} quad;
/** TGSI exec things */
struct {
struct sp_tgsi_sampler *sampler[PIPE_SHADER_TYPES];
struct sp_tgsi_image *image[PIPE_SHADER_TYPES];
struct sp_tgsi_buffer *buffer[PIPE_SHADER_TYPES];
} tgsi;
struct tgsi_exec_machine *fs_machine;
/** whether early depth testing is enabled */
bool early_depth;
/** The primitive drawing context */
struct draw_context *draw;
/** Draw module backend */
struct vbuf_render *vbuf_backend;
struct draw_stage *vbuf;
struct blitter_context *blitter;
boolean dirty_render_cache;
struct softpipe_tile_cache *cbuf_cache[PIPE_MAX_COLOR_BUFS];
struct softpipe_tile_cache *zsbuf_cache;
unsigned tex_timestamp;
/*
* Texture caches for vertex, fragment, geometry stages.
* Don't use PIPE_SHADER_TYPES here to avoid allocating unused memory
* for compute shaders.
* XXX wouldn't it make more sense for the tile cache to just be part
* of sp_sampler_view?
*/
struct softpipe_tex_tile_cache *tex_cache[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS];
unsigned dump_fs : 1;
unsigned dump_gs : 1;
unsigned dump_cs : 1;
unsigned no_rast : 1;
};
static inline struct softpipe_context *
softpipe_context( struct pipe_context *pipe )
{
return (struct softpipe_context *)pipe;
}
struct pipe_context *
softpipe_create_context(struct pipe_screen *, void *priv, unsigned flags);
struct pipe_resource *
softpipe_user_buffer_create(struct pipe_screen *screen,
void *ptr,
unsigned bytes,
unsigned bind_flags);
#define SP_UNREFERENCED 0
#define SP_REFERENCED_FOR_READ (1 << 0)
#define SP_REFERENCED_FOR_WRITE (1 << 1)
unsigned int
softpipe_is_resource_referenced( struct pipe_context *pipe,
struct pipe_resource *texture,
unsigned level, int layer);
#endif /* SP_CONTEXT_H */
/**************************************************************************
*
* Copyright 2007 VMware, Inc.
* All Rights Reserved.
*
* 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, sub license, 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 (including the
* next paragraph) 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 NON-INFRINGEMENT.
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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.
*
**************************************************************************/
/* Author:
* Brian Paul
* Keith Whitwell
*/
#include "pipe/p_defines.h"
#include "pipe/p_context.h"
#include "util/u_inlines.h"
#include "util/u_draw.h"
#include "util/u_prim.h"
#include "sp_context.h"
#include "sp_query.h"
#include "sp_state.h"
#include "sp_texture.h"
#include "sp_screen.h"
#include "draw/draw_context.h"
/**
* This function handles drawing indexed and non-indexed prims,
* instanced and non-instanced drawing, with or without min/max element
* indexes.
* All the other drawing functions are expressed in terms of this
* function.
*
* For non-indexed prims, indexBuffer should be NULL.
* For non-instanced drawing, instanceCount should be 1.
* When the min/max element indexes aren't known, minIndex should be 0
* and maxIndex should be ~0.
*/
void
softpipe_draw_vbo(struct pipe_context *pipe,
const struct pipe_draw_info *info)
{
struct softpipe_context *sp = softpipe_context(pipe);
struct draw_context *draw = sp->draw;
const void *mapped_indices = NULL;
unsigned i;
if (!softpipe_check_render_cond(sp))
return;
if (info->indirect) {
util_draw_indirect(pipe, info);
return;
}
sp->reduced_api_prim = u_reduced_prim(info->mode);
if (sp->dirty) {
softpipe_update_derived(sp, sp->reduced_api_prim);
}
/* Map vertex buffers */
for (i = 0; i < sp->num_vertex_buffers; i++) {
const void *buf = sp->vertex_buffer[i].is_user_buffer ?
sp->vertex_buffer[i].buffer.user : NULL;
size_t size = ~0;
if (!buf) {
if (!sp->vertex_buffer[i].buffer.resource) {
continue;
}
buf = softpipe_resource_data(sp->vertex_buffer[i].buffer.resource);
size = sp->vertex_buffer[i].buffer.resource->width0;
}
draw_set_mapped_vertex_buffer(draw, i, buf, size);
}
/* Map index buffer, if present */
if (info->index_size) {
unsigned available_space = ~0;
mapped_indices = info->has_user_indices ? info->index.user : NULL;
if (!mapped_indices) {
mapped_indices = softpipe_resource_data(info->index.resource);
available_space = info->index.resource->width0;
}
draw_set_indexes(draw,
(ubyte *) mapped_indices,
info->index_size, available_space);
}
for (i = 0; i < sp->num_so_targets; i++) {
void *buf = 0;
if (sp->so_targets[i]) {
buf = softpipe_resource(sp->so_targets[i]->target.buffer)->data;
sp->so_targets[i]->mapping = buf;
}
}
draw_set_mapped_so_targets(draw, sp->num_so_targets,
sp->so_targets);
if (softpipe_screen(sp->pipe.screen)->use_llvm) {
softpipe_prepare_vertex_sampling(sp,
sp->num_sampler_views[PIPE_SHADER_VERTEX],
sp->sampler_views[PIPE_SHADER_VERTEX]);
softpipe_prepare_geometry_sampling(sp,
sp->num_sampler_views[PIPE_SHADER_GEOMETRY],
sp->sampler_views[PIPE_SHADER_GEOMETRY]);
}
if (sp->gs && !sp->gs->shader.tokens) {
/* we have an empty geometry shader with stream output, so
attach the stream output info to the current vertex shader */
if (sp->vs) {
draw_vs_attach_so(sp->vs->draw_data, &sp->gs->shader.stream_output);
}
}
draw_collect_pipeline_statistics(draw,
sp->active_statistics_queries > 0);
/* draw! */
draw_vbo(draw, info);
/* unmap vertex/index buffers - will cause draw module to flush */
for (i = 0; i < sp->num_vertex_buffers; i++) {
draw_set_mapped_vertex_buffer(draw, i, NULL, 0);
}
if (mapped_indices) {
draw_set_indexes(draw, NULL, 0, 0);
}
draw_set_mapped_so_targets(draw, 0, NULL);
if (softpipe_screen(sp->pipe.screen)->use_llvm) {
softpipe_cleanup_vertex_sampling(sp);
softpipe_cleanup_geometry_sampling(sp);
}
/*
* TODO: Flush only when a user vertex/index buffer is present
* (or even better, modify draw module to do this
* internally when this condition is seen?)
*/
draw_flush(draw);
/* Note: leave drawing surfaces mapped */
sp->dirty_render_cache = TRUE;
}
/**************************************************************************
*
* Copyright 2010 VMware, Inc.
* All Rights Reserved.
*
* 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, sub license, 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 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 NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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.
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
**************************************************************************/
#include "pipe/p_screen.h"
#include "util/u_debug.h"
#include "sp_fence.h"
static void
softpipe_fence_reference(struct pipe_screen *screen,
struct pipe_fence_handle **ptr,
struct pipe_fence_handle *fence)
{
*ptr = fence;
}
static boolean
softpipe_fence_finish(struct pipe_screen *screen,
struct pipe_context *ctx,
struct pipe_fence_handle *fence,
uint64_t timeout)
{
assert(fence);
return TRUE;
}
void
softpipe_init_screen_fence_funcs(struct pipe_screen *screen)
{
screen->fence_reference = softpipe_fence_reference;
screen->fence_finish = softpipe_fence_finish;
}
/**************************************************************************
*
* Copyright 2010 VMware, Inc.
* All Rights Reserved.
*
* 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, sub license, 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 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 NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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.
*