1848b8605Smrg/********************************************************** 2848b8605Smrg * Copyright 2008-2009 VMware, Inc. All rights reserved. 3848b8605Smrg * 4848b8605Smrg * Permission is hereby granted, free of charge, to any person 5848b8605Smrg * obtaining a copy of this software and associated documentation 6848b8605Smrg * files (the "Software"), to deal in the Software without 7848b8605Smrg * restriction, including without limitation the rights to use, copy, 8848b8605Smrg * modify, merge, publish, distribute, sublicense, and/or sell copies 9848b8605Smrg * of the Software, and to permit persons to whom the Software is 10848b8605Smrg * furnished to do so, subject to the following conditions: 11848b8605Smrg * 12848b8605Smrg * The above copyright notice and this permission notice shall be 13848b8605Smrg * included in all copies or substantial portions of the Software. 14848b8605Smrg * 15848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16848b8605Smrg * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17848b8605Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18848b8605Smrg * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19848b8605Smrg * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20848b8605Smrg * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21848b8605Smrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22848b8605Smrg * SOFTWARE. 23848b8605Smrg * 24848b8605Smrg **********************************************************/ 25848b8605Smrg 26b8e80941Smrg#include "git_sha1.h" /* For MESA_GIT_SHA1 */ 27848b8605Smrg#include "util/u_format.h" 28848b8605Smrg#include "util/u_memory.h" 29848b8605Smrg#include "util/u_inlines.h" 30b8e80941Smrg#include "util/u_screen.h" 31848b8605Smrg#include "util/u_string.h" 32848b8605Smrg#include "util/u_math.h" 33848b8605Smrg 34b8e80941Smrg#include "os/os_process.h" 35b8e80941Smrg 36848b8605Smrg#include "svga_winsys.h" 37848b8605Smrg#include "svga_public.h" 38848b8605Smrg#include "svga_context.h" 39848b8605Smrg#include "svga_format.h" 40848b8605Smrg#include "svga_screen.h" 41b8e80941Smrg#include "svga_tgsi.h" 42848b8605Smrg#include "svga_resource_texture.h" 43848b8605Smrg#include "svga_resource.h" 44848b8605Smrg#include "svga_debug.h" 45848b8605Smrg 46848b8605Smrg#include "svga3d_shaderdefs.h" 47b8e80941Smrg#include "VGPU10ShaderTokens.h" 48848b8605Smrg 49b8e80941Smrg/* NOTE: this constant may get moved into a svga3d*.h header file */ 50b8e80941Smrg#define SVGA3D_DX_MAX_RESOURCE_SIZE (128 * 1024 * 1024) 51848b8605Smrg 52848b8605Smrg#ifdef DEBUG 53848b8605Smrgint SVGA_DEBUG = 0; 54848b8605Smrg 55848b8605Smrgstatic const struct debug_named_value svga_debug_flags[] = { 56b8e80941Smrg { "dma", DEBUG_DMA, NULL }, 57b8e80941Smrg { "tgsi", DEBUG_TGSI, NULL }, 58b8e80941Smrg { "pipe", DEBUG_PIPE, NULL }, 59b8e80941Smrg { "state", DEBUG_STATE, NULL }, 60b8e80941Smrg { "screen", DEBUG_SCREEN, NULL }, 61b8e80941Smrg { "tex", DEBUG_TEX, NULL }, 62b8e80941Smrg { "swtnl", DEBUG_SWTNL, NULL }, 63b8e80941Smrg { "const", DEBUG_CONSTS, NULL }, 64b8e80941Smrg { "viewport", DEBUG_VIEWPORT, NULL }, 65b8e80941Smrg { "views", DEBUG_VIEWS, NULL }, 66b8e80941Smrg { "perf", DEBUG_PERF, NULL }, 67b8e80941Smrg { "flush", DEBUG_FLUSH, NULL }, 68b8e80941Smrg { "sync", DEBUG_SYNC, NULL }, 69b8e80941Smrg { "cache", DEBUG_CACHE, NULL }, 70b8e80941Smrg { "streamout", DEBUG_STREAMOUT, NULL }, 71b8e80941Smrg { "query", DEBUG_QUERY, NULL }, 72b8e80941Smrg { "samplers", DEBUG_SAMPLERS, NULL }, 73848b8605Smrg DEBUG_NAMED_VALUE_END 74848b8605Smrg}; 75848b8605Smrg#endif 76848b8605Smrg 77848b8605Smrgstatic const char * 78848b8605Smrgsvga_get_vendor( struct pipe_screen *pscreen ) 79848b8605Smrg{ 80848b8605Smrg return "VMware, Inc."; 81848b8605Smrg} 82848b8605Smrg 83848b8605Smrg 84848b8605Smrgstatic const char * 85848b8605Smrgsvga_get_name( struct pipe_screen *pscreen ) 86848b8605Smrg{ 87848b8605Smrg const char *build = "", *llvm = "", *mutex = ""; 88848b8605Smrg static char name[100]; 89848b8605Smrg#ifdef DEBUG 90848b8605Smrg /* Only return internal details in the DEBUG version: 91848b8605Smrg */ 92848b8605Smrg build = "build: DEBUG;"; 93848b8605Smrg mutex = "mutex: " PIPE_ATOMIC ";"; 94848b8605Smrg#else 95848b8605Smrg build = "build: RELEASE;"; 96848b8605Smrg#endif 97b8e80941Smrg#ifdef HAVE_LLVM 98b8e80941Smrg llvm = "LLVM;"; 99b8e80941Smrg#endif 100848b8605Smrg 101848b8605Smrg util_snprintf(name, sizeof(name), "SVGA3D; %s %s %s", build, mutex, llvm); 102848b8605Smrg return name; 103848b8605Smrg} 104848b8605Smrg 105848b8605Smrg 106b8e80941Smrg/** Helper for querying float-valued device cap */ 107b8e80941Smrgstatic float 108b8e80941Smrgget_float_cap(struct svga_winsys_screen *sws, SVGA3dDevCapIndex cap, 109b8e80941Smrg float defaultVal) 110b8e80941Smrg{ 111b8e80941Smrg SVGA3dDevCapResult result; 112b8e80941Smrg if (sws->get_cap(sws, cap, &result)) 113b8e80941Smrg return result.f; 114b8e80941Smrg else 115b8e80941Smrg return defaultVal; 116b8e80941Smrg} 117b8e80941Smrg 118b8e80941Smrg 119b8e80941Smrg/** Helper for querying uint-valued device cap */ 120b8e80941Smrgstatic unsigned 121b8e80941Smrgget_uint_cap(struct svga_winsys_screen *sws, SVGA3dDevCapIndex cap, 122b8e80941Smrg unsigned defaultVal) 123b8e80941Smrg{ 124b8e80941Smrg SVGA3dDevCapResult result; 125b8e80941Smrg if (sws->get_cap(sws, cap, &result)) 126b8e80941Smrg return result.u; 127b8e80941Smrg else 128b8e80941Smrg return defaultVal; 129b8e80941Smrg} 130b8e80941Smrg 131b8e80941Smrg 132b8e80941Smrg/** Helper for querying boolean-valued device cap */ 133b8e80941Smrgstatic boolean 134b8e80941Smrgget_bool_cap(struct svga_winsys_screen *sws, SVGA3dDevCapIndex cap, 135b8e80941Smrg boolean defaultVal) 136b8e80941Smrg{ 137b8e80941Smrg SVGA3dDevCapResult result; 138b8e80941Smrg if (sws->get_cap(sws, cap, &result)) 139b8e80941Smrg return result.b; 140b8e80941Smrg else 141b8e80941Smrg return defaultVal; 142b8e80941Smrg} 143848b8605Smrg 144848b8605Smrg 145848b8605Smrgstatic float 146848b8605Smrgsvga_get_paramf(struct pipe_screen *screen, enum pipe_capf param) 147848b8605Smrg{ 148848b8605Smrg struct svga_screen *svgascreen = svga_screen(screen); 149848b8605Smrg struct svga_winsys_screen *sws = svgascreen->sws; 150848b8605Smrg 151848b8605Smrg switch (param) { 152848b8605Smrg case PIPE_CAPF_MAX_LINE_WIDTH: 153848b8605Smrg return svgascreen->maxLineWidth; 154848b8605Smrg case PIPE_CAPF_MAX_LINE_WIDTH_AA: 155848b8605Smrg return svgascreen->maxLineWidthAA; 156848b8605Smrg 157848b8605Smrg case PIPE_CAPF_MAX_POINT_WIDTH: 158848b8605Smrg /* fall-through */ 159848b8605Smrg case PIPE_CAPF_MAX_POINT_WIDTH_AA: 160848b8605Smrg return svgascreen->maxPointSize; 161848b8605Smrg 162848b8605Smrg case PIPE_CAPF_MAX_TEXTURE_ANISOTROPY: 163b8e80941Smrg return (float) get_uint_cap(sws, SVGA3D_DEVCAP_MAX_TEXTURE_ANISOTROPY, 4); 164848b8605Smrg 165848b8605Smrg case PIPE_CAPF_MAX_TEXTURE_LOD_BIAS: 166848b8605Smrg return 15.0; 167b8e80941Smrg 168b8e80941Smrg case PIPE_CAPF_MIN_CONSERVATIVE_RASTER_DILATE: 169b8e80941Smrg /* fall-through */ 170b8e80941Smrg case PIPE_CAPF_MAX_CONSERVATIVE_RASTER_DILATE: 171b8e80941Smrg /* fall-through */ 172b8e80941Smrg case PIPE_CAPF_CONSERVATIVE_RASTER_DILATE_GRANULARITY: 173b8e80941Smrg return 0.0f; 174b8e80941Smrg 175848b8605Smrg } 176848b8605Smrg 177848b8605Smrg debug_printf("Unexpected PIPE_CAPF_ query %u\n", param); 178848b8605Smrg return 0; 179848b8605Smrg} 180848b8605Smrg 181848b8605Smrg 182848b8605Smrgstatic int 183848b8605Smrgsvga_get_param(struct pipe_screen *screen, enum pipe_cap param) 184848b8605Smrg{ 185848b8605Smrg struct svga_screen *svgascreen = svga_screen(screen); 186848b8605Smrg struct svga_winsys_screen *sws = svgascreen->sws; 187848b8605Smrg SVGA3dDevCapResult result; 188848b8605Smrg 189848b8605Smrg switch (param) { 190848b8605Smrg case PIPE_CAP_NPOT_TEXTURES: 191848b8605Smrg case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES: 192b8e80941Smrg case PIPE_CAP_MIXED_COLOR_DEPTH_BITS: 193848b8605Smrg return 1; 194848b8605Smrg case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS: 195b8e80941Smrg /* 196b8e80941Smrg * "In virtually every OpenGL implementation and hardware, 197b8e80941Smrg * GL_MAX_DUAL_SOURCE_DRAW_BUFFERS is 1" 198b8e80941Smrg * http://www.opengl.org/wiki/Blending 199b8e80941Smrg */ 200b8e80941Smrg return sws->have_vgpu10 ? 1 : 0; 201848b8605Smrg case PIPE_CAP_ANISOTROPIC_FILTER: 202848b8605Smrg return 1; 203848b8605Smrg case PIPE_CAP_POINT_SPRITE: 204848b8605Smrg return 1; 205848b8605Smrg case PIPE_CAP_TGSI_TEXCOORD: 206848b8605Smrg return 0; 207848b8605Smrg case PIPE_CAP_MAX_RENDER_TARGETS: 208848b8605Smrg return svgascreen->max_color_buffers; 209848b8605Smrg case PIPE_CAP_OCCLUSION_QUERY: 210848b8605Smrg return 1; 211848b8605Smrg case PIPE_CAP_QUERY_TIME_ELAPSED: 212848b8605Smrg return 0; 213b8e80941Smrg case PIPE_CAP_TEXTURE_BUFFER_OBJECTS: 214b8e80941Smrg return sws->have_vgpu10; 215848b8605Smrg case PIPE_CAP_TEXTURE_SWIZZLE: 216848b8605Smrg return 1; 217848b8605Smrg case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK: 218848b8605Smrg return 0; 219848b8605Smrg case PIPE_CAP_USER_VERTEX_BUFFERS: 220848b8605Smrg return 0; 221848b8605Smrg case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT: 222b8e80941Smrg return 256; 223848b8605Smrg 224848b8605Smrg case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: 225848b8605Smrg { 226848b8605Smrg unsigned levels = SVGA_MAX_TEXTURE_LEVELS; 227848b8605Smrg if (sws->get_cap(sws, SVGA3D_DEVCAP_MAX_TEXTURE_WIDTH, &result)) 228848b8605Smrg levels = MIN2(util_logbase2(result.u) + 1, levels); 229848b8605Smrg else 230848b8605Smrg levels = 12 /* 2048x2048 */; 231848b8605Smrg if (sws->get_cap(sws, SVGA3D_DEVCAP_MAX_TEXTURE_HEIGHT, &result)) 232848b8605Smrg levels = MIN2(util_logbase2(result.u) + 1, levels); 233848b8605Smrg else 234848b8605Smrg levels = 12 /* 2048x2048 */; 235848b8605Smrg return levels; 236848b8605Smrg } 237848b8605Smrg 238848b8605Smrg case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: 239848b8605Smrg if (!sws->get_cap(sws, SVGA3D_DEVCAP_MAX_VOLUME_EXTENT, &result)) 240848b8605Smrg return 8; /* max 128x128x128 */ 241848b8605Smrg return MIN2(util_logbase2(result.u) + 1, SVGA_MAX_TEXTURE_LEVELS); 242848b8605Smrg 243848b8605Smrg case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: 244848b8605Smrg /* 245848b8605Smrg * No mechanism to query the host, and at least limited to 2048x2048 on 246848b8605Smrg * certain hardware. 247848b8605Smrg */ 248848b8605Smrg return MIN2(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS), 249848b8605Smrg 12 /* 2048x2048 */); 250848b8605Smrg 251b8e80941Smrg case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS: 252b8e80941Smrg return sws->have_vgpu10 ? SVGA3D_MAX_SURFACE_ARRAYSIZE : 0; 253b8e80941Smrg 254848b8605Smrg case PIPE_CAP_BLEND_EQUATION_SEPARATE: /* req. for GL 1.5 */ 255848b8605Smrg return 1; 256848b8605Smrg 257848b8605Smrg case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: 258848b8605Smrg return 1; 259848b8605Smrg case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: 260b8e80941Smrg return sws->have_vgpu10; 261848b8605Smrg case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: 262848b8605Smrg return 0; 263848b8605Smrg case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: 264b8e80941Smrg return !sws->have_vgpu10; 265848b8605Smrg 266848b8605Smrg case PIPE_CAP_VERTEX_COLOR_UNCLAMPED: 267848b8605Smrg return 1; /* The color outputs of vertex shaders are not clamped */ 268848b8605Smrg case PIPE_CAP_VERTEX_COLOR_CLAMPED: 269848b8605Smrg return 0; /* The driver can't clamp vertex colors */ 270848b8605Smrg case PIPE_CAP_FRAGMENT_COLOR_CLAMPED: 271848b8605Smrg return 0; /* The driver can't clamp fragment colors */ 272848b8605Smrg 273848b8605Smrg case PIPE_CAP_MIXED_COLORBUFFER_FORMATS: 274848b8605Smrg return 1; /* expected for GL_ARB_framebuffer_object */ 275848b8605Smrg 276848b8605Smrg case PIPE_CAP_GLSL_FEATURE_LEVEL: 277b8e80941Smrg return sws->have_vgpu10 ? 330 : 120; 278b8e80941Smrg 279b8e80941Smrg case PIPE_CAP_GLSL_FEATURE_LEVEL_COMPATIBILITY: 280b8e80941Smrg return sws->have_vgpu10 ? 330 : 120; 281848b8605Smrg 282848b8605Smrg case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER: 283b8e80941Smrg case PIPE_CAP_DEPTH_CLIP_DISABLE_SEPARATE: 284848b8605Smrg return 0; 285848b8605Smrg 286848b8605Smrg case PIPE_CAP_SM3: 287848b8605Smrg return 1; 288848b8605Smrg 289848b8605Smrg case PIPE_CAP_DEPTH_CLIP_DISABLE: 290848b8605Smrg case PIPE_CAP_INDEP_BLEND_ENABLE: 291b8e80941Smrg case PIPE_CAP_CONDITIONAL_RENDER: 292b8e80941Smrg case PIPE_CAP_QUERY_TIMESTAMP: 293848b8605Smrg case PIPE_CAP_TGSI_INSTANCEID: 294848b8605Smrg case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR: 295b8e80941Smrg case PIPE_CAP_SEAMLESS_CUBE_MAP: 296b8e80941Smrg case PIPE_CAP_FAKE_SW_MSAA: 297b8e80941Smrg return sws->have_vgpu10; 298b8e80941Smrg 299b8e80941Smrg case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS: 300b8e80941Smrg return sws->have_vgpu10 ? SVGA3D_DX_MAX_SOTARGETS : 0; 301b8e80941Smrg case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS: 302b8e80941Smrg return sws->have_vgpu10 ? 4 : 0; 303b8e80941Smrg case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS: 304b8e80941Smrg return sws->have_vgpu10 ? SVGA3D_MAX_STREAMOUT_DECLS : 0; 305b8e80941Smrg case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME: 306b8e80941Smrg case PIPE_CAP_STREAM_OUTPUT_INTERLEAVE_BUFFERS: 307b8e80941Smrg return 0; 308b8e80941Smrg case PIPE_CAP_TEXTURE_MULTISAMPLE: 309b8e80941Smrg return svgascreen->ms_samples ? 1 : 0; 310b8e80941Smrg 311b8e80941Smrg case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE: 312b8e80941Smrg /* convert bytes to texels for the case of the largest texel 313b8e80941Smrg * size: float[4]. 314b8e80941Smrg */ 315b8e80941Smrg return SVGA3D_DX_MAX_RESOURCE_SIZE / (4 * sizeof(float)); 316b8e80941Smrg 317848b8605Smrg case PIPE_CAP_MIN_TEXEL_OFFSET: 318b8e80941Smrg return sws->have_vgpu10 ? VGPU10_MIN_TEXEL_FETCH_OFFSET : 0; 319848b8605Smrg case PIPE_CAP_MAX_TEXEL_OFFSET: 320b8e80941Smrg return sws->have_vgpu10 ? VGPU10_MAX_TEXEL_FETCH_OFFSET : 0; 321b8e80941Smrg 322848b8605Smrg case PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET: 323848b8605Smrg case PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET: 324b8e80941Smrg return 0; 325b8e80941Smrg 326848b8605Smrg case PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES: 327b8e80941Smrg return sws->have_vgpu10 ? 256 : 0; 328848b8605Smrg case PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS: 329b8e80941Smrg return sws->have_vgpu10 ? 1024 : 0; 330b8e80941Smrg 331b8e80941Smrg case PIPE_CAP_PRIMITIVE_RESTART: 332b8e80941Smrg return 1; /* may be a sw fallback, depending on restart index */ 333b8e80941Smrg 334b8e80941Smrg case PIPE_CAP_GENERATE_MIPMAP: 335b8e80941Smrg return sws->have_generate_mipmap_cmd; 336b8e80941Smrg 337b8e80941Smrg case PIPE_CAP_NATIVE_FENCE_FD: 338b8e80941Smrg return sws->have_fence_fd; 339b8e80941Smrg 340b8e80941Smrg case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION: 341b8e80941Smrg return 1; 342b8e80941Smrg 343b8e80941Smrg case PIPE_CAP_CUBE_MAP_ARRAY: 344b8e80941Smrg case PIPE_CAP_INDEP_BLEND_FUNC: 345b8e80941Smrg case PIPE_CAP_SAMPLE_SHADING: 346b8e80941Smrg case PIPE_CAP_FORCE_PERSAMPLE_INTERP: 347b8e80941Smrg case PIPE_CAP_TEXTURE_QUERY_LOD: 348b8e80941Smrg return sws->have_sm4_1; 349b8e80941Smrg 350b8e80941Smrg case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS: 351b8e80941Smrg return sws->have_sm4_1 ? 1 : 0; /* only single-channel textures */ 352b8e80941Smrg case PIPE_CAP_MAX_VARYINGS: 353b8e80941Smrg return sws->have_vgpu10 ? VGPU10_MAX_FS_INPUTS : 10; 354b8e80941Smrg 355b8e80941Smrg /* Unsupported features */ 356b8e80941Smrg case PIPE_CAP_TEXTURE_MIRROR_CLAMP: 357b8e80941Smrg case PIPE_CAP_TEXTURE_MIRROR_CLAMP_TO_EDGE: 358b8e80941Smrg case PIPE_CAP_SHADER_STENCIL_EXPORT: 359b8e80941Smrg case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE: 360b8e80941Smrg case PIPE_CAP_TEXTURE_BARRIER: 361848b8605Smrg case PIPE_CAP_MAX_VERTEX_STREAMS: 362848b8605Smrg case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS: 363848b8605Smrg case PIPE_CAP_COMPUTE: 364848b8605Smrg case PIPE_CAP_START_INSTANCE: 365848b8605Smrg case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT: 366848b8605Smrg case PIPE_CAP_QUERY_PIPELINE_STATISTICS: 367848b8605Smrg case PIPE_CAP_TGSI_VS_LAYER_VIEWPORT: 368848b8605Smrg case PIPE_CAP_TEXTURE_GATHER_SM5: 369848b8605Smrg case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT: 370848b8605Smrg case PIPE_CAP_TEXTURE_GATHER_OFFSETS: 371848b8605Smrg case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION: 372848b8605Smrg case PIPE_CAP_DRAW_INDIRECT: 373b8e80941Smrg case PIPE_CAP_MULTI_DRAW_INDIRECT: 374b8e80941Smrg case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS: 375848b8605Smrg case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE: 376848b8605Smrg case PIPE_CAP_CONDITIONAL_RENDER_INVERTED: 377b8e80941Smrg case PIPE_CAP_SAMPLER_VIEW_TARGET: 378b8e80941Smrg case PIPE_CAP_CLIP_HALFZ: 379b8e80941Smrg case PIPE_CAP_VERTEXID_NOBASE: 380b8e80941Smrg case PIPE_CAP_POLYGON_OFFSET_CLAMP: 381b8e80941Smrg case PIPE_CAP_MULTISAMPLE_Z_RESOLVE: 382b8e80941Smrg case PIPE_CAP_TGSI_PACK_HALF_FLOAT: 383b8e80941Smrg case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT: 384b8e80941Smrg case PIPE_CAP_INVALIDATE_BUFFER: 385b8e80941Smrg case PIPE_CAP_STRING_MARKER: 386b8e80941Smrg case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS: 387b8e80941Smrg case PIPE_CAP_QUERY_MEMORY_INFO: 388b8e80941Smrg case PIPE_CAP_PCI_GROUP: 389b8e80941Smrg case PIPE_CAP_PCI_BUS: 390b8e80941Smrg case PIPE_CAP_PCI_DEVICE: 391b8e80941Smrg case PIPE_CAP_PCI_FUNCTION: 392b8e80941Smrg case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR: 393b8e80941Smrg case PIPE_CAP_CONSERVATIVE_RASTER_POST_SNAP_TRIANGLES: 394b8e80941Smrg case PIPE_CAP_CONSERVATIVE_RASTER_POST_SNAP_POINTS_LINES: 395b8e80941Smrg case PIPE_CAP_CONSERVATIVE_RASTER_PRE_SNAP_TRIANGLES: 396b8e80941Smrg case PIPE_CAP_CONSERVATIVE_RASTER_PRE_SNAP_POINTS_LINES: 397b8e80941Smrg case PIPE_CAP_CONSERVATIVE_RASTER_POST_DEPTH_COVERAGE: 398b8e80941Smrg case PIPE_CAP_MAX_CONSERVATIVE_RASTER_SUBPIXEL_PRECISION_BIAS: 399b8e80941Smrg case PIPE_CAP_MAX_TEXTURE_UPLOAD_MEMORY_BUDGET: 400848b8605Smrg return 0; 401848b8605Smrg case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT: 402848b8605Smrg return 64; 403b8e80941Smrg case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY: 404b8e80941Smrg case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY: 405848b8605Smrg case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY: 406b8e80941Smrg return 1; /* need 4-byte alignment for all offsets and strides */ 407b8e80941Smrg case PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE: 408b8e80941Smrg return 2048; 409848b8605Smrg case PIPE_CAP_MAX_VIEWPORTS: 410848b8605Smrg return 1; 411848b8605Smrg case PIPE_CAP_ENDIANNESS: 412848b8605Smrg return PIPE_ENDIAN_LITTLE; 413848b8605Smrg 414848b8605Smrg case PIPE_CAP_VENDOR_ID: 415848b8605Smrg return 0x15ad; /* VMware Inc. */ 416848b8605Smrg case PIPE_CAP_DEVICE_ID: 417848b8605Smrg return 0x0405; /* assume SVGA II */ 418848b8605Smrg case PIPE_CAP_ACCELERATED: 419848b8605Smrg return 0; /* XXX: */ 420848b8605Smrg case PIPE_CAP_VIDEO_MEMORY: 421848b8605Smrg /* XXX: Query the host ? */ 422848b8605Smrg return 1; 423b8e80941Smrg case PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS: 424b8e80941Smrg return sws->have_vgpu10; 425b8e80941Smrg case PIPE_CAP_CLEAR_TEXTURE: 426b8e80941Smrg return sws->have_vgpu10; 427848b8605Smrg case PIPE_CAP_UMA: 428b8e80941Smrg case PIPE_CAP_RESOURCE_FROM_USER_MEMORY: 429b8e80941Smrg case PIPE_CAP_DEVICE_RESET_STATUS_QUERY: 430b8e80941Smrg case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS: 431b8e80941Smrg case PIPE_CAP_TEXTURE_FLOAT_LINEAR: 432b8e80941Smrg case PIPE_CAP_TEXTURE_HALF_FLOAT_LINEAR: 433b8e80941Smrg case PIPE_CAP_DEPTH_BOUNDS_TEST: 434b8e80941Smrg case PIPE_CAP_TGSI_TXQS: 435b8e80941Smrg case PIPE_CAP_SHAREABLE_SHADERS: 436b8e80941Smrg case PIPE_CAP_DRAW_PARAMETERS: 437b8e80941Smrg case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL: 438b8e80941Smrg case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL: 439b8e80941Smrg case PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY: 440b8e80941Smrg case PIPE_CAP_QUERY_BUFFER_OBJECT: 441b8e80941Smrg case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT: 442b8e80941Smrg case PIPE_CAP_CULL_DISTANCE: 443b8e80941Smrg case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES: 444b8e80941Smrg case PIPE_CAP_TGSI_VOTE: 445b8e80941Smrg case PIPE_CAP_MAX_WINDOW_RECTANGLES: 446b8e80941Smrg case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED: 447b8e80941Smrg case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS: 448b8e80941Smrg case PIPE_CAP_TGSI_ARRAY_COMPONENTS: 449b8e80941Smrg case PIPE_CAP_TGSI_CAN_READ_OUTPUTS: 450b8e80941Smrg case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY: 451b8e80941Smrg case PIPE_CAP_TGSI_FS_FBFETCH: 452b8e80941Smrg case PIPE_CAP_TGSI_MUL_ZERO_WINS: 453b8e80941Smrg case PIPE_CAP_DOUBLES: 454b8e80941Smrg case PIPE_CAP_INT64: 455b8e80941Smrg case PIPE_CAP_INT64_DIVMOD: 456b8e80941Smrg case PIPE_CAP_TGSI_TEX_TXF_LZ: 457b8e80941Smrg case PIPE_CAP_TGSI_CLOCK: 458b8e80941Smrg case PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE: 459b8e80941Smrg case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE: 460b8e80941Smrg case PIPE_CAP_TGSI_BALLOT: 461b8e80941Smrg case PIPE_CAP_TGSI_TES_LAYER_VIEWPORT: 462b8e80941Smrg case PIPE_CAP_CAN_BIND_CONST_BUFFER_AS_VERTEX: 463b8e80941Smrg case PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION: 464b8e80941Smrg case PIPE_CAP_POST_DEPTH_COVERAGE: 465b8e80941Smrg case PIPE_CAP_BINDLESS_TEXTURE: 466b8e80941Smrg case PIPE_CAP_NIR_SAMPLERS_AS_DEREF: 467b8e80941Smrg case PIPE_CAP_QUERY_SO_OVERFLOW: 468b8e80941Smrg case PIPE_CAP_MEMOBJ: 469b8e80941Smrg case PIPE_CAP_LOAD_CONSTBUF: 470b8e80941Smrg case PIPE_CAP_TGSI_ANY_REG_AS_ADDRESS: 471b8e80941Smrg case PIPE_CAP_TILE_RASTER_ORDER: 472b8e80941Smrg case PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES: 473b8e80941Smrg case PIPE_CAP_FRAMEBUFFER_MSAA_CONSTRAINTS: 474b8e80941Smrg case PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET: 475b8e80941Smrg case PIPE_CAP_CONTEXT_PRIORITY_MASK: 476b8e80941Smrg case PIPE_CAP_FENCE_SIGNAL: 477b8e80941Smrg case PIPE_CAP_CONSTBUF0_FLAGS: 478b8e80941Smrg case PIPE_CAP_PACKED_UNIFORMS: 479b8e80941Smrg case PIPE_CAP_PROGRAMMABLE_SAMPLE_LOCATIONS: 480848b8605Smrg return 0; 481b8e80941Smrg case PIPE_CAP_TGSI_DIV: 482b8e80941Smrg return 1; 483b8e80941Smrg case PIPE_CAP_MAX_GS_INVOCATIONS: 484b8e80941Smrg return 32; 485b8e80941Smrg case PIPE_CAP_MAX_SHADER_BUFFER_SIZE: 486b8e80941Smrg return 1 << 27; 487b8e80941Smrg default: 488b8e80941Smrg return u_pipe_screen_get_param_defaults(screen, param); 489848b8605Smrg } 490848b8605Smrg} 491848b8605Smrg 492b8e80941Smrg 493b8e80941Smrgstatic int 494b8e80941Smrgvgpu9_get_shader_param(struct pipe_screen *screen, 495b8e80941Smrg enum pipe_shader_type shader, 496b8e80941Smrg enum pipe_shader_cap param) 497848b8605Smrg{ 498848b8605Smrg struct svga_screen *svgascreen = svga_screen(screen); 499848b8605Smrg struct svga_winsys_screen *sws = svgascreen->sws; 500b8e80941Smrg unsigned val; 501b8e80941Smrg 502b8e80941Smrg assert(!sws->have_vgpu10); 503848b8605Smrg 504848b8605Smrg switch (shader) 505848b8605Smrg { 506848b8605Smrg case PIPE_SHADER_FRAGMENT: 507848b8605Smrg switch (param) 508848b8605Smrg { 509848b8605Smrg case PIPE_SHADER_CAP_MAX_INSTRUCTIONS: 510848b8605Smrg case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS: 511b8e80941Smrg return get_uint_cap(sws, 512b8e80941Smrg SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_INSTRUCTIONS, 513b8e80941Smrg 512); 514848b8605Smrg case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS: 515848b8605Smrg case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS: 516848b8605Smrg return 512; 517848b8605Smrg case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH: 518848b8605Smrg return SVGA3D_MAX_NESTING_LEVEL; 519848b8605Smrg case PIPE_SHADER_CAP_MAX_INPUTS: 520848b8605Smrg return 10; 521b8e80941Smrg case PIPE_SHADER_CAP_MAX_OUTPUTS: 522b8e80941Smrg return svgascreen->max_color_buffers; 523848b8605Smrg case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE: 524848b8605Smrg return 224 * sizeof(float[4]); 525848b8605Smrg case PIPE_SHADER_CAP_MAX_CONST_BUFFERS: 526848b8605Smrg return 1; 527848b8605Smrg case PIPE_SHADER_CAP_MAX_TEMPS: 528b8e80941Smrg val = get_uint_cap(sws, SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_TEMPS, 32); 529b8e80941Smrg return MIN2(val, SVGA3D_TEMPREG_MAX); 530848b8605Smrg case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR: 531b8e80941Smrg /* 532b8e80941Smrg * Although PS 3.0 has some addressing abilities it can only represent 533b8e80941Smrg * loops that can be statically determined and unrolled. Given we can 534b8e80941Smrg * only handle a subset of the cases that the state tracker already 535b8e80941Smrg * does it is better to defer loop unrolling to the state tracker. 536b8e80941Smrg */ 537848b8605Smrg return 0; 538848b8605Smrg case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED: 539848b8605Smrg return 0; 540848b8605Smrg case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED: 541848b8605Smrg return 0; 542848b8605Smrg case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR: 543848b8605Smrg case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR: 544848b8605Smrg case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR: 545848b8605Smrg return 0; 546848b8605Smrg case PIPE_SHADER_CAP_SUBROUTINES: 547848b8605Smrg return 0; 548b8e80941Smrg case PIPE_SHADER_CAP_INT64_ATOMICS: 549848b8605Smrg case PIPE_SHADER_CAP_INTEGERS: 550848b8605Smrg return 0; 551b8e80941Smrg case PIPE_SHADER_CAP_FP16: 552b8e80941Smrg return 0; 553848b8605Smrg case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: 554848b8605Smrg case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS: 555848b8605Smrg return 16; 556848b8605Smrg case PIPE_SHADER_CAP_PREFERRED_IR: 557848b8605Smrg return PIPE_SHADER_IR_TGSI; 558b8e80941Smrg case PIPE_SHADER_CAP_SUPPORTED_IRS: 559b8e80941Smrg return 0; 560b8e80941Smrg case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: 561b8e80941Smrg case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: 562b8e80941Smrg case PIPE_SHADER_CAP_TGSI_LDEXP_SUPPORTED: 563b8e80941Smrg case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: 564b8e80941Smrg case PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE: 565b8e80941Smrg case PIPE_SHADER_CAP_MAX_SHADER_BUFFERS: 566b8e80941Smrg case PIPE_SHADER_CAP_MAX_SHADER_IMAGES: 567b8e80941Smrg case PIPE_SHADER_CAP_LOWER_IF_THRESHOLD: 568b8e80941Smrg case PIPE_SHADER_CAP_TGSI_SKIP_MERGE_REGISTERS: 569b8e80941Smrg case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTERS: 570b8e80941Smrg case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER_BUFFERS: 571848b8605Smrg return 0; 572b8e80941Smrg case PIPE_SHADER_CAP_SCALAR_ISA: 573b8e80941Smrg return 1; 574b8e80941Smrg case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT: 575b8e80941Smrg return 32; 576848b8605Smrg } 577848b8605Smrg /* If we get here, we failed to handle a cap above */ 578848b8605Smrg debug_printf("Unexpected fragment shader query %u\n", param); 579848b8605Smrg return 0; 580848b8605Smrg case PIPE_SHADER_VERTEX: 581848b8605Smrg switch (param) 582848b8605Smrg { 583848b8605Smrg case PIPE_SHADER_CAP_MAX_INSTRUCTIONS: 584848b8605Smrg case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS: 585b8e80941Smrg return get_uint_cap(sws, SVGA3D_DEVCAP_MAX_VERTEX_SHADER_INSTRUCTIONS, 586b8e80941Smrg 512); 587848b8605Smrg case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS: 588848b8605Smrg case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS: 589848b8605Smrg /* XXX: until we have vertex texture support */ 590848b8605Smrg return 0; 591848b8605Smrg case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH: 592848b8605Smrg return SVGA3D_MAX_NESTING_LEVEL; 593848b8605Smrg case PIPE_SHADER_CAP_MAX_INPUTS: 594848b8605Smrg return 16; 595b8e80941Smrg case PIPE_SHADER_CAP_MAX_OUTPUTS: 596b8e80941Smrg return 10; 597848b8605Smrg case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE: 598848b8605Smrg return 256 * sizeof(float[4]); 599848b8605Smrg case PIPE_SHADER_CAP_MAX_CONST_BUFFERS: 600848b8605Smrg return 1; 601848b8605Smrg case PIPE_SHADER_CAP_MAX_TEMPS: 602b8e80941Smrg val = get_uint_cap(sws, SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEMPS, 32); 603b8e80941Smrg return MIN2(val, SVGA3D_TEMPREG_MAX); 604848b8605Smrg case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED: 605848b8605Smrg return 0; 606848b8605Smrg case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED: 607848b8605Smrg return 0; 608848b8605Smrg case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR: 609848b8605Smrg case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR: 610848b8605Smrg return 1; 611848b8605Smrg case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR: 612848b8605Smrg return 0; 613848b8605Smrg case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR: 614848b8605Smrg return 1; 615848b8605Smrg case PIPE_SHADER_CAP_SUBROUTINES: 616848b8605Smrg return 0; 617b8e80941Smrg case PIPE_SHADER_CAP_INT64_ATOMICS: 618848b8605Smrg case PIPE_SHADER_CAP_INTEGERS: 619848b8605Smrg return 0; 620b8e80941Smrg case PIPE_SHADER_CAP_FP16: 621b8e80941Smrg return 0; 622848b8605Smrg case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: 623848b8605Smrg case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS: 624848b8605Smrg return 0; 625848b8605Smrg case PIPE_SHADER_CAP_PREFERRED_IR: 626848b8605Smrg return PIPE_SHADER_IR_TGSI; 627b8e80941Smrg case PIPE_SHADER_CAP_SUPPORTED_IRS: 628848b8605Smrg return 0; 629b8e80941Smrg case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: 630b8e80941Smrg case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: 631b8e80941Smrg case PIPE_SHADER_CAP_TGSI_LDEXP_SUPPORTED: 632b8e80941Smrg case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: 633b8e80941Smrg case PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE: 634b8e80941Smrg case PIPE_SHADER_CAP_MAX_SHADER_BUFFERS: 635b8e80941Smrg case PIPE_SHADER_CAP_MAX_SHADER_IMAGES: 636b8e80941Smrg case PIPE_SHADER_CAP_LOWER_IF_THRESHOLD: 637b8e80941Smrg case PIPE_SHADER_CAP_TGSI_SKIP_MERGE_REGISTERS: 638b8e80941Smrg case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTERS: 639b8e80941Smrg case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER_BUFFERS: 640b8e80941Smrg return 0; 641b8e80941Smrg case PIPE_SHADER_CAP_SCALAR_ISA: 642b8e80941Smrg return 1; 643b8e80941Smrg case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT: 644b8e80941Smrg return 32; 645848b8605Smrg } 646848b8605Smrg /* If we get here, we failed to handle a cap above */ 647848b8605Smrg debug_printf("Unexpected vertex shader query %u\n", param); 648848b8605Smrg return 0; 649848b8605Smrg case PIPE_SHADER_GEOMETRY: 650848b8605Smrg case PIPE_SHADER_COMPUTE: 651b8e80941Smrg case PIPE_SHADER_TESS_CTRL: 652b8e80941Smrg case PIPE_SHADER_TESS_EVAL: 653b8e80941Smrg /* no support for geometry, tess or compute shaders at this time */ 654848b8605Smrg return 0; 655848b8605Smrg default: 656848b8605Smrg debug_printf("Unexpected shader type (%u) query\n", shader); 657848b8605Smrg return 0; 658848b8605Smrg } 659848b8605Smrg return 0; 660848b8605Smrg} 661848b8605Smrg 662848b8605Smrg 663b8e80941Smrgstatic int 664b8e80941Smrgvgpu10_get_shader_param(struct pipe_screen *screen, 665b8e80941Smrg enum pipe_shader_type shader, 666b8e80941Smrg enum pipe_shader_cap param) 667848b8605Smrg{ 668b8e80941Smrg struct svga_screen *svgascreen = svga_screen(screen); 669b8e80941Smrg struct svga_winsys_screen *sws = svgascreen->sws; 670848b8605Smrg 671b8e80941Smrg assert(sws->have_vgpu10); 672b8e80941Smrg (void) sws; /* silence unused var warnings in non-debug builds */ 673848b8605Smrg 674b8e80941Smrg /* Only VS, GS, FS supported */ 675b8e80941Smrg if (shader != PIPE_SHADER_VERTEX && 676b8e80941Smrg shader != PIPE_SHADER_GEOMETRY && 677b8e80941Smrg shader != PIPE_SHADER_FRAGMENT) { 678b8e80941Smrg return 0; 679848b8605Smrg } 680848b8605Smrg 681b8e80941Smrg /* NOTE: we do not query the device for any caps/limits at this time */ 682848b8605Smrg 683b8e80941Smrg /* Generally the same limits for vertex, geometry and fragment shaders */ 684b8e80941Smrg switch (param) { 685b8e80941Smrg case PIPE_SHADER_CAP_MAX_INSTRUCTIONS: 686b8e80941Smrg case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS: 687b8e80941Smrg case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS: 688b8e80941Smrg case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS: 689b8e80941Smrg return 64 * 1024; 690b8e80941Smrg case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH: 691b8e80941Smrg return 64; 692b8e80941Smrg case PIPE_SHADER_CAP_MAX_INPUTS: 693b8e80941Smrg if (shader == PIPE_SHADER_FRAGMENT) 694b8e80941Smrg return VGPU10_MAX_FS_INPUTS; 695b8e80941Smrg else if (shader == PIPE_SHADER_GEOMETRY) 696b8e80941Smrg return VGPU10_MAX_GS_INPUTS; 697b8e80941Smrg else 698b8e80941Smrg return VGPU10_MAX_VS_INPUTS; 699b8e80941Smrg case PIPE_SHADER_CAP_MAX_OUTPUTS: 700b8e80941Smrg if (shader == PIPE_SHADER_FRAGMENT) 701b8e80941Smrg return VGPU10_MAX_FS_OUTPUTS; 702b8e80941Smrg else if (shader == PIPE_SHADER_GEOMETRY) 703b8e80941Smrg return VGPU10_MAX_GS_OUTPUTS; 704b8e80941Smrg else 705b8e80941Smrg return VGPU10_MAX_VS_OUTPUTS; 706b8e80941Smrg case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE: 707b8e80941Smrg return VGPU10_MAX_CONSTANT_BUFFER_ELEMENT_COUNT * sizeof(float[4]); 708b8e80941Smrg case PIPE_SHADER_CAP_MAX_CONST_BUFFERS: 709b8e80941Smrg return svgascreen->max_const_buffers; 710b8e80941Smrg case PIPE_SHADER_CAP_MAX_TEMPS: 711b8e80941Smrg return VGPU10_MAX_TEMPS; 712b8e80941Smrg case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR: 713b8e80941Smrg case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR: 714b8e80941Smrg case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR: 715b8e80941Smrg case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR: 716b8e80941Smrg return TRUE; /* XXX verify */ 717b8e80941Smrg case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED: 718b8e80941Smrg case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED: 719b8e80941Smrg case PIPE_SHADER_CAP_SUBROUTINES: 720b8e80941Smrg case PIPE_SHADER_CAP_INTEGERS: 721b8e80941Smrg return TRUE; 722b8e80941Smrg case PIPE_SHADER_CAP_FP16: 723b8e80941Smrg return FALSE; 724b8e80941Smrg case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: 725b8e80941Smrg case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS: 726b8e80941Smrg return SVGA3D_DX_MAX_SAMPLERS; 727b8e80941Smrg case PIPE_SHADER_CAP_PREFERRED_IR: 728b8e80941Smrg return PIPE_SHADER_IR_TGSI; 729b8e80941Smrg case PIPE_SHADER_CAP_SUPPORTED_IRS: 730b8e80941Smrg return 0; 731b8e80941Smrg case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: 732b8e80941Smrg case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: 733b8e80941Smrg case PIPE_SHADER_CAP_TGSI_LDEXP_SUPPORTED: 734b8e80941Smrg case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: 735b8e80941Smrg case PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE: 736b8e80941Smrg case PIPE_SHADER_CAP_MAX_SHADER_BUFFERS: 737b8e80941Smrg case PIPE_SHADER_CAP_MAX_SHADER_IMAGES: 738b8e80941Smrg case PIPE_SHADER_CAP_LOWER_IF_THRESHOLD: 739b8e80941Smrg case PIPE_SHADER_CAP_TGSI_SKIP_MERGE_REGISTERS: 740b8e80941Smrg case PIPE_SHADER_CAP_INT64_ATOMICS: 741b8e80941Smrg case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTERS: 742b8e80941Smrg case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER_BUFFERS: 743b8e80941Smrg return 0; 744b8e80941Smrg case PIPE_SHADER_CAP_SCALAR_ISA: 745b8e80941Smrg return 1; 746b8e80941Smrg case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT: 747b8e80941Smrg return 32; 748b8e80941Smrg default: 749b8e80941Smrg debug_printf("Unexpected vgpu10 shader query %u\n", param); 750b8e80941Smrg return 0; 751848b8605Smrg } 752b8e80941Smrg return 0; 753b8e80941Smrg} 754848b8605Smrg 755848b8605Smrg 756b8e80941Smrgstatic int 757b8e80941Smrgsvga_get_shader_param(struct pipe_screen *screen, enum pipe_shader_type shader, 758b8e80941Smrg enum pipe_shader_cap param) 759b8e80941Smrg{ 760b8e80941Smrg struct svga_screen *svgascreen = svga_screen(screen); 761b8e80941Smrg struct svga_winsys_screen *sws = svgascreen->sws; 762b8e80941Smrg if (sws->have_vgpu10) { 763b8e80941Smrg return vgpu10_get_shader_param(screen, shader, param); 764848b8605Smrg } 765b8e80941Smrg else { 766b8e80941Smrg return vgpu9_get_shader_param(screen, shader, param); 767848b8605Smrg } 768848b8605Smrg} 769848b8605Smrg 770848b8605Smrg 771848b8605Smrgstatic void 772848b8605Smrgsvga_fence_reference(struct pipe_screen *screen, 773848b8605Smrg struct pipe_fence_handle **ptr, 774848b8605Smrg struct pipe_fence_handle *fence) 775848b8605Smrg{ 776848b8605Smrg struct svga_winsys_screen *sws = svga_screen(screen)->sws; 777848b8605Smrg sws->fence_reference(sws, ptr, fence); 778848b8605Smrg} 779848b8605Smrg 780848b8605Smrg 781848b8605Smrgstatic boolean 782b8e80941Smrgsvga_fence_finish(struct pipe_screen *screen, 783b8e80941Smrg struct pipe_context *ctx, 784b8e80941Smrg struct pipe_fence_handle *fence, 785b8e80941Smrg uint64_t timeout) 786848b8605Smrg{ 787848b8605Smrg struct svga_winsys_screen *sws = svga_screen(screen)->sws; 788b8e80941Smrg boolean retVal; 789b8e80941Smrg 790b8e80941Smrg SVGA_STATS_TIME_PUSH(sws, SVGA_STATS_TIME_FENCEFINISH); 791b8e80941Smrg 792b8e80941Smrg if (!timeout) { 793b8e80941Smrg retVal = sws->fence_signalled(sws, fence, 0) == 0; 794b8e80941Smrg } 795b8e80941Smrg else { 796b8e80941Smrg SVGA_DBG(DEBUG_DMA|DEBUG_PERF, "%s fence_ptr %p\n", 797b8e80941Smrg __FUNCTION__, fence); 798b8e80941Smrg 799b8e80941Smrg retVal = sws->fence_finish(sws, fence, timeout, 0) == 0; 800b8e80941Smrg } 801b8e80941Smrg 802b8e80941Smrg SVGA_STATS_TIME_POP(sws); 803b8e80941Smrg 804b8e80941Smrg return retVal; 805848b8605Smrg} 806848b8605Smrg 807848b8605Smrg 808b8e80941Smrgstatic int 809b8e80941Smrgsvga_fence_get_fd(struct pipe_screen *screen, 810b8e80941Smrg struct pipe_fence_handle *fence) 811848b8605Smrg{ 812848b8605Smrg struct svga_winsys_screen *sws = svga_screen(screen)->sws; 813848b8605Smrg 814b8e80941Smrg return sws->fence_get_fd(sws, fence, TRUE); 815848b8605Smrg} 816848b8605Smrg 817848b8605Smrg 818848b8605Smrgstatic int 819848b8605Smrgsvga_get_driver_query_info(struct pipe_screen *screen, 820848b8605Smrg unsigned index, 821848b8605Smrg struct pipe_driver_query_info *info) 822848b8605Smrg{ 823b8e80941Smrg#define QUERY(NAME, ENUM, UNITS) \ 824b8e80941Smrg {NAME, ENUM, {0}, UNITS, PIPE_DRIVER_QUERY_RESULT_TYPE_AVERAGE, 0, 0x0} 825b8e80941Smrg 826848b8605Smrg static const struct pipe_driver_query_info queries[] = { 827b8e80941Smrg /* per-frame counters */ 828b8e80941Smrg QUERY("num-draw-calls", SVGA_QUERY_NUM_DRAW_CALLS, 829b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_UINT64), 830b8e80941Smrg QUERY("num-fallbacks", SVGA_QUERY_NUM_FALLBACKS, 831b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_UINT64), 832b8e80941Smrg QUERY("num-flushes", SVGA_QUERY_NUM_FLUSHES, 833b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_UINT64), 834b8e80941Smrg QUERY("num-validations", SVGA_QUERY_NUM_VALIDATIONS, 835b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_UINT64), 836b8e80941Smrg QUERY("map-buffer-time", SVGA_QUERY_MAP_BUFFER_TIME, 837b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_MICROSECONDS), 838b8e80941Smrg QUERY("num-buffers-mapped", SVGA_QUERY_NUM_BUFFERS_MAPPED, 839b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_UINT64), 840b8e80941Smrg QUERY("num-textures-mapped", SVGA_QUERY_NUM_TEXTURES_MAPPED, 841b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_UINT64), 842b8e80941Smrg QUERY("num-bytes-uploaded", SVGA_QUERY_NUM_BYTES_UPLOADED, 843b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_BYTES), 844b8e80941Smrg QUERY("command-buffer-size", SVGA_QUERY_COMMAND_BUFFER_SIZE, 845b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_BYTES), 846b8e80941Smrg QUERY("flush-time", SVGA_QUERY_FLUSH_TIME, 847b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_MICROSECONDS), 848b8e80941Smrg QUERY("surface-write-flushes", SVGA_QUERY_SURFACE_WRITE_FLUSHES, 849b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_UINT64), 850b8e80941Smrg QUERY("num-readbacks", SVGA_QUERY_NUM_READBACKS, 851b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_UINT64), 852b8e80941Smrg QUERY("num-resource-updates", SVGA_QUERY_NUM_RESOURCE_UPDATES, 853b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_UINT64), 854b8e80941Smrg QUERY("num-buffer-uploads", SVGA_QUERY_NUM_BUFFER_UPLOADS, 855b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_UINT64), 856b8e80941Smrg QUERY("num-const-buf-updates", SVGA_QUERY_NUM_CONST_BUF_UPDATES, 857b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_UINT64), 858b8e80941Smrg QUERY("num-const-updates", SVGA_QUERY_NUM_CONST_UPDATES, 859b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_UINT64), 860b8e80941Smrg 861b8e80941Smrg /* running total counters */ 862b8e80941Smrg QUERY("memory-used", SVGA_QUERY_MEMORY_USED, 863b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_BYTES), 864b8e80941Smrg QUERY("num-shaders", SVGA_QUERY_NUM_SHADERS, 865b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_UINT64), 866b8e80941Smrg QUERY("num-resources", SVGA_QUERY_NUM_RESOURCES, 867b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_UINT64), 868b8e80941Smrg QUERY("num-state-objects", SVGA_QUERY_NUM_STATE_OBJECTS, 869b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_UINT64), 870b8e80941Smrg QUERY("num-surface-views", SVGA_QUERY_NUM_SURFACE_VIEWS, 871b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_UINT64), 872b8e80941Smrg QUERY("num-generate-mipmap", SVGA_QUERY_NUM_GENERATE_MIPMAP, 873b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_UINT64), 874b8e80941Smrg QUERY("num-failed-allocations", SVGA_QUERY_NUM_FAILED_ALLOCATIONS, 875b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_UINT64), 876b8e80941Smrg QUERY("num-commands-per-draw", SVGA_QUERY_NUM_COMMANDS_PER_DRAW, 877b8e80941Smrg PIPE_DRIVER_QUERY_TYPE_FLOAT), 878848b8605Smrg }; 879b8e80941Smrg#undef QUERY 880848b8605Smrg 881848b8605Smrg if (!info) 882b8e80941Smrg return ARRAY_SIZE(queries); 883848b8605Smrg 884b8e80941Smrg if (index >= ARRAY_SIZE(queries)) 885848b8605Smrg return 0; 886848b8605Smrg 887848b8605Smrg *info = queries[index]; 888848b8605Smrg return 1; 889848b8605Smrg} 890848b8605Smrg 891848b8605Smrg 892b8e80941Smrgstatic void 893b8e80941Smrginit_logging(struct pipe_screen *screen) 894b8e80941Smrg{ 895b8e80941Smrg struct svga_screen *svgascreen = svga_screen(screen); 896b8e80941Smrg static const char *log_prefix = "Mesa: "; 897b8e80941Smrg char host_log[1000]; 898b8e80941Smrg 899b8e80941Smrg /* Log Version to Host */ 900b8e80941Smrg util_snprintf(host_log, sizeof(host_log) - strlen(log_prefix), 901b8e80941Smrg "%s%s\n", log_prefix, svga_get_name(screen)); 902b8e80941Smrg svgascreen->sws->host_log(svgascreen->sws, host_log); 903b8e80941Smrg 904b8e80941Smrg util_snprintf(host_log, sizeof(host_log) - strlen(log_prefix), 905b8e80941Smrg "%s" PACKAGE_VERSION MESA_GIT_SHA1, log_prefix); 906b8e80941Smrg svgascreen->sws->host_log(svgascreen->sws, host_log); 907b8e80941Smrg 908b8e80941Smrg /* If the SVGA_EXTRA_LOGGING env var is set, log the process's command 909b8e80941Smrg * line (program name and arguments). 910b8e80941Smrg */ 911b8e80941Smrg if (debug_get_bool_option("SVGA_EXTRA_LOGGING", FALSE)) { 912b8e80941Smrg char cmdline[1000]; 913b8e80941Smrg if (os_get_command_line(cmdline, sizeof(cmdline))) { 914b8e80941Smrg util_snprintf(host_log, sizeof(host_log) - strlen(log_prefix), 915b8e80941Smrg "%s%s\n", log_prefix, cmdline); 916b8e80941Smrg svgascreen->sws->host_log(svgascreen->sws, host_log); 917b8e80941Smrg } 918b8e80941Smrg } 919b8e80941Smrg} 920b8e80941Smrg 921b8e80941Smrg 922b8e80941Smrg/** 923b8e80941Smrg * no-op logging function to use when SVGA_NO_LOGGING is set. 924b8e80941Smrg */ 925b8e80941Smrgstatic void 926b8e80941Smrgnop_host_log(struct svga_winsys_screen *sws, const char *message) 927b8e80941Smrg{ 928b8e80941Smrg /* nothing */ 929b8e80941Smrg} 930b8e80941Smrg 931b8e80941Smrg 932848b8605Smrgstatic void 933848b8605Smrgsvga_destroy_screen( struct pipe_screen *screen ) 934848b8605Smrg{ 935848b8605Smrg struct svga_screen *svgascreen = svga_screen(screen); 936b8e80941Smrg 937848b8605Smrg svga_screen_cache_cleanup(svgascreen); 938848b8605Smrg 939b8e80941Smrg mtx_destroy(&svgascreen->swc_mutex); 940b8e80941Smrg mtx_destroy(&svgascreen->tex_mutex); 941848b8605Smrg 942848b8605Smrg svgascreen->sws->destroy(svgascreen->sws); 943b8e80941Smrg 944848b8605Smrg FREE(svgascreen); 945848b8605Smrg} 946848b8605Smrg 947848b8605Smrg 948848b8605Smrg/** 949848b8605Smrg * Create a new svga_screen object 950848b8605Smrg */ 951848b8605Smrgstruct pipe_screen * 952848b8605Smrgsvga_screen_create(struct svga_winsys_screen *sws) 953848b8605Smrg{ 954848b8605Smrg struct svga_screen *svgascreen; 955848b8605Smrg struct pipe_screen *screen; 956848b8605Smrg 957848b8605Smrg#ifdef DEBUG 958848b8605Smrg SVGA_DEBUG = debug_get_flags_option("SVGA_DEBUG", svga_debug_flags, 0 ); 959848b8605Smrg#endif 960848b8605Smrg 961848b8605Smrg svgascreen = CALLOC_STRUCT(svga_screen); 962848b8605Smrg if (!svgascreen) 963848b8605Smrg goto error1; 964848b8605Smrg 965848b8605Smrg svgascreen->debug.force_level_surface_view = 966848b8605Smrg debug_get_bool_option("SVGA_FORCE_LEVEL_SURFACE_VIEW", FALSE); 967848b8605Smrg svgascreen->debug.force_surface_view = 968848b8605Smrg debug_get_bool_option("SVGA_FORCE_SURFACE_VIEW", FALSE); 969848b8605Smrg svgascreen->debug.force_sampler_view = 970848b8605Smrg debug_get_bool_option("SVGA_FORCE_SAMPLER_VIEW", FALSE); 971848b8605Smrg svgascreen->debug.no_surface_view = 972848b8605Smrg debug_get_bool_option("SVGA_NO_SURFACE_VIEW", FALSE); 973848b8605Smrg svgascreen->debug.no_sampler_view = 974848b8605Smrg debug_get_bool_option("SVGA_NO_SAMPLER_VIEW", FALSE); 975b8e80941Smrg svgascreen->debug.no_cache_index_buffers = 976b8e80941Smrg debug_get_bool_option("SVGA_NO_CACHE_INDEX_BUFFERS", FALSE); 977848b8605Smrg 978848b8605Smrg screen = &svgascreen->screen; 979848b8605Smrg 980848b8605Smrg screen->destroy = svga_destroy_screen; 981848b8605Smrg screen->get_name = svga_get_name; 982848b8605Smrg screen->get_vendor = svga_get_vendor; 983b8e80941Smrg screen->get_device_vendor = svga_get_vendor; // TODO actual device vendor 984848b8605Smrg screen->get_param = svga_get_param; 985848b8605Smrg screen->get_shader_param = svga_get_shader_param; 986848b8605Smrg screen->get_paramf = svga_get_paramf; 987b8e80941Smrg screen->get_timestamp = NULL; 988848b8605Smrg screen->is_format_supported = svga_is_format_supported; 989848b8605Smrg screen->context_create = svga_context_create; 990848b8605Smrg screen->fence_reference = svga_fence_reference; 991848b8605Smrg screen->fence_finish = svga_fence_finish; 992b8e80941Smrg screen->fence_get_fd = svga_fence_get_fd; 993b8e80941Smrg 994848b8605Smrg screen->get_driver_query_info = svga_get_driver_query_info; 995848b8605Smrg svgascreen->sws = sws; 996848b8605Smrg 997848b8605Smrg svga_init_screen_resource_functions(svgascreen); 998848b8605Smrg 999848b8605Smrg if (sws->get_hw_version) { 1000848b8605Smrg svgascreen->hw_version = sws->get_hw_version(sws); 1001848b8605Smrg } else { 1002848b8605Smrg svgascreen->hw_version = SVGA3D_HWVERSION_WS65_B1; 1003848b8605Smrg } 1004848b8605Smrg 1005b8e80941Smrg if (svgascreen->hw_version < SVGA3D_HWVERSION_WS8_B1) { 1006b8e80941Smrg /* too old for 3D acceleration */ 1007b8e80941Smrg debug_printf("Hardware version 0x%x is too old for accerated 3D\n", 1008b8e80941Smrg svgascreen->hw_version); 1009b8e80941Smrg goto error2; 1010b8e80941Smrg } 1011848b8605Smrg 1012b8e80941Smrg debug_printf("%s enabled = %u\n", 1013b8e80941Smrg sws->have_sm4_1 ? "SM4_1" : "VGPU10", 1014b8e80941Smrg sws->have_sm4_1 ? 1 : sws->have_vgpu10); 1015848b8605Smrg 1016b8e80941Smrg debug_printf("Mesa: %s %s (%s)\n", svga_get_name(screen), 1017b8e80941Smrg PACKAGE_VERSION, MESA_GIT_SHA1); 1018848b8605Smrg 1019848b8605Smrg /* 1020848b8605Smrg * The D16, D24X8, and D24S8 formats always do an implicit shadow compare 1021848b8605Smrg * when sampled from, where as the DF16, DF24, and D24S8_INT do not. So 1022848b8605Smrg * we prefer the later when available. 1023848b8605Smrg * 1024848b8605Smrg * This mimics hardware vendors extensions for D3D depth sampling. See also 1025848b8605Smrg * http://aras-p.info/texts/D3D9GPUHacks.html 1026848b8605Smrg */ 1027848b8605Smrg 1028848b8605Smrg { 1029848b8605Smrg boolean has_df16, has_df24, has_d24s8_int; 1030848b8605Smrg SVGA3dSurfaceFormatCaps caps; 1031848b8605Smrg SVGA3dSurfaceFormatCaps mask; 1032848b8605Smrg mask.value = 0; 1033848b8605Smrg mask.zStencil = 1; 1034848b8605Smrg mask.texture = 1; 1035848b8605Smrg 1036848b8605Smrg svgascreen->depth.z16 = SVGA3D_Z_D16; 1037848b8605Smrg svgascreen->depth.x8z24 = SVGA3D_Z_D24X8; 1038848b8605Smrg svgascreen->depth.s8z24 = SVGA3D_Z_D24S8; 1039848b8605Smrg 1040848b8605Smrg svga_get_format_cap(svgascreen, SVGA3D_Z_DF16, &caps); 1041848b8605Smrg has_df16 = (caps.value & mask.value) == mask.value; 1042848b8605Smrg 1043848b8605Smrg svga_get_format_cap(svgascreen, SVGA3D_Z_DF24, &caps); 1044848b8605Smrg has_df24 = (caps.value & mask.value) == mask.value; 1045848b8605Smrg 1046848b8605Smrg svga_get_format_cap(svgascreen, SVGA3D_Z_D24S8_INT, &caps); 1047848b8605Smrg has_d24s8_int = (caps.value & mask.value) == mask.value; 1048848b8605Smrg 1049848b8605Smrg /* XXX: We might want some other logic here. 1050848b8605Smrg * Like if we only have d24s8_int we should 1051848b8605Smrg * emulate the other formats with that. 1052848b8605Smrg */ 1053848b8605Smrg if (has_df16) { 1054848b8605Smrg svgascreen->depth.z16 = SVGA3D_Z_DF16; 1055848b8605Smrg } 1056848b8605Smrg if (has_df24) { 1057848b8605Smrg svgascreen->depth.x8z24 = SVGA3D_Z_DF24; 1058848b8605Smrg } 1059848b8605Smrg if (has_d24s8_int) { 1060848b8605Smrg svgascreen->depth.s8z24 = SVGA3D_Z_D24S8_INT; 1061848b8605Smrg } 1062848b8605Smrg } 1063848b8605Smrg 1064848b8605Smrg /* Query device caps 1065848b8605Smrg */ 1066b8e80941Smrg if (sws->have_vgpu10) { 1067b8e80941Smrg svgascreen->haveProvokingVertex 1068b8e80941Smrg = get_bool_cap(sws, SVGA3D_DEVCAP_DX_PROVOKING_VERTEX, FALSE); 1069b8e80941Smrg svgascreen->haveLineSmooth = TRUE; 1070b8e80941Smrg svgascreen->maxPointSize = 80.0F; 1071b8e80941Smrg svgascreen->max_color_buffers = SVGA3D_DX_MAX_RENDER_TARGETS; 1072b8e80941Smrg 1073b8e80941Smrg /* Multisample samples per pixel */ 1074b8e80941Smrg if (sws->have_sm4_1 && debug_get_bool_option("SVGA_MSAA", TRUE)) { 1075b8e80941Smrg if (get_bool_cap(sws, SVGA3D_DEVCAP_MULTISAMPLE_2X, FALSE)) 1076b8e80941Smrg svgascreen->ms_samples |= 1 << 1; 1077b8e80941Smrg if (get_bool_cap(sws, SVGA3D_DEVCAP_MULTISAMPLE_4X, FALSE)) 1078b8e80941Smrg svgascreen->ms_samples |= 1 << 3; 1079b8e80941Smrg } 1080848b8605Smrg 1081b8e80941Smrg /* Maximum number of constant buffers */ 1082b8e80941Smrg svgascreen->max_const_buffers = 1083b8e80941Smrg get_uint_cap(sws, SVGA3D_DEVCAP_DX_MAX_CONSTANT_BUFFERS, 1); 1084b8e80941Smrg assert(svgascreen->max_const_buffers <= SVGA_MAX_CONST_BUFS); 1085848b8605Smrg 1086b8e80941Smrg screen->is_format_supported = svga_is_dx_format_supported; 1087b8e80941Smrg } 1088b8e80941Smrg else { 1089b8e80941Smrg /* VGPU9 */ 1090b8e80941Smrg unsigned vs_ver = get_uint_cap(sws, SVGA3D_DEVCAP_VERTEX_SHADER_VERSION, 1091b8e80941Smrg SVGA3DVSVERSION_NONE); 1092b8e80941Smrg unsigned fs_ver = get_uint_cap(sws, SVGA3D_DEVCAP_FRAGMENT_SHADER_VERSION, 1093b8e80941Smrg SVGA3DPSVERSION_NONE); 1094b8e80941Smrg 1095b8e80941Smrg /* we require Shader model 3.0 or later */ 1096b8e80941Smrg if (fs_ver < SVGA3DPSVERSION_30 || vs_ver < SVGA3DVSVERSION_30) { 1097b8e80941Smrg goto error2; 1098b8e80941Smrg } 1099848b8605Smrg 1100b8e80941Smrg svgascreen->haveProvokingVertex = FALSE; 1101848b8605Smrg 1102b8e80941Smrg svgascreen->haveLineSmooth = 1103b8e80941Smrg get_bool_cap(sws, SVGA3D_DEVCAP_LINE_AA, FALSE); 1104848b8605Smrg 1105b8e80941Smrg svgascreen->maxPointSize = 1106b8e80941Smrg get_float_cap(sws, SVGA3D_DEVCAP_MAX_POINT_SIZE, 1.0f); 1107b8e80941Smrg /* Keep this to a reasonable size to avoid failures in conform/pntaa.c */ 1108b8e80941Smrg svgascreen->maxPointSize = MIN2(svgascreen->maxPointSize, 80.0f); 1109b8e80941Smrg 1110b8e80941Smrg /* The SVGA3D device always supports 4 targets at this time, regardless 1111b8e80941Smrg * of what querying SVGA3D_DEVCAP_MAX_RENDER_TARGETS might return. 1112848b8605Smrg */ 1113b8e80941Smrg svgascreen->max_color_buffers = 4; 1114b8e80941Smrg 1115b8e80941Smrg /* Only support one constant buffer 1116b8e80941Smrg */ 1117b8e80941Smrg svgascreen->max_const_buffers = 1; 1118b8e80941Smrg 1119b8e80941Smrg /* No multisampling */ 1120b8e80941Smrg svgascreen->ms_samples = 0; 1121848b8605Smrg } 1122848b8605Smrg 1123b8e80941Smrg /* common VGPU9 / VGPU10 caps */ 1124b8e80941Smrg svgascreen->haveLineStipple = 1125b8e80941Smrg get_bool_cap(sws, SVGA3D_DEVCAP_LINE_STIPPLE, FALSE); 1126b8e80941Smrg 1127b8e80941Smrg svgascreen->maxLineWidth = 1128b8e80941Smrg MAX2(1.0, get_float_cap(sws, SVGA3D_DEVCAP_MAX_LINE_WIDTH, 1.0f)); 1129b8e80941Smrg 1130b8e80941Smrg svgascreen->maxLineWidthAA = 1131b8e80941Smrg MAX2(1.0, get_float_cap(sws, SVGA3D_DEVCAP_MAX_AA_LINE_WIDTH, 1.0f)); 1132b8e80941Smrg 1133b8e80941Smrg if (0) { 1134b8e80941Smrg debug_printf("svga: haveProvokingVertex %u\n", 1135b8e80941Smrg svgascreen->haveProvokingVertex); 1136b8e80941Smrg debug_printf("svga: haveLineStip %u " 1137b8e80941Smrg "haveLineSmooth %u maxLineWidth %.2f maxLineWidthAA %.2f\n", 1138b8e80941Smrg svgascreen->haveLineStipple, svgascreen->haveLineSmooth, 1139b8e80941Smrg svgascreen->maxLineWidth, svgascreen->maxLineWidthAA); 1140b8e80941Smrg debug_printf("svga: maxPointSize %g\n", svgascreen->maxPointSize); 1141b8e80941Smrg debug_printf("svga: msaa samples mask: 0x%x\n", svgascreen->ms_samples); 1142b8e80941Smrg } 1143848b8605Smrg 1144b8e80941Smrg (void) mtx_init(&svgascreen->tex_mutex, mtx_plain); 1145b8e80941Smrg (void) mtx_init(&svgascreen->swc_mutex, mtx_recursive); 1146848b8605Smrg 1147848b8605Smrg svga_screen_cache_init(svgascreen); 1148848b8605Smrg 1149b8e80941Smrg if (debug_get_bool_option("SVGA_NO_LOGGING", FALSE) == TRUE) { 1150b8e80941Smrg svgascreen->sws->host_log = nop_host_log; 1151b8e80941Smrg } else { 1152b8e80941Smrg init_logging(screen); 1153b8e80941Smrg } 1154b8e80941Smrg 1155848b8605Smrg return screen; 1156848b8605Smrgerror2: 1157848b8605Smrg FREE(svgascreen); 1158848b8605Smrgerror1: 1159848b8605Smrg return NULL; 1160848b8605Smrg} 1161848b8605Smrg 1162b8e80941Smrg 1163848b8605Smrgstruct svga_winsys_screen * 1164848b8605Smrgsvga_winsys_screen(struct pipe_screen *screen) 1165848b8605Smrg{ 1166848b8605Smrg return svga_screen(screen)->sws; 1167848b8605Smrg} 1168848b8605Smrg 1169b8e80941Smrg 1170848b8605Smrg#ifdef DEBUG 1171848b8605Smrgstruct svga_screen * 1172848b8605Smrgsvga_screen(struct pipe_screen *screen) 1173848b8605Smrg{ 1174848b8605Smrg assert(screen); 1175848b8605Smrg assert(screen->destroy == svga_destroy_screen); 1176848b8605Smrg return (struct svga_screen *)screen; 1177848b8605Smrg} 1178848b8605Smrg#endif 1179