From e88f99c1c0f693cc2c15f0a4d56537251124fc61 Mon Sep 17 00:00:00 2001 From: Courtney Goeltzenleuchter Date: Wed, 25 Feb 2015 11:46:58 -0700 Subject: demos: Add use_staging option Specifying --use_staging as a command line argument to tri will force tri to upload the texture via a linear mapped staging buffer. --- demos/tri.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/demos/tri.c b/demos/tri.c index d77d7739..e497c670 100644 --- a/demos/tri.c +++ b/demos/tri.c @@ -96,6 +96,7 @@ struct demo { #endif bool quit; + bool use_staging_buffer; uint32_t current_buffer; }; @@ -533,7 +534,7 @@ static void demo_prepare_textures(struct demo *demo) assert(!err); for (i = 0; i < DEMO_TEXTURE_COUNT; i++) { - if (props.linearTilingFeatures & XGL_FORMAT_IMAGE_SHADER_READ_BIT) { + if ((props.linearTilingFeatures & XGL_FORMAT_IMAGE_SHADER_READ_BIT) && !demo->use_staging_buffer) { /* Device can texture using linear textures */ demo_prepare_texture_image(demo, tex_colors[i], &demo->textures[i], XGL_LINEAR_TILING, XGL_MEMORY_PROPERTY_CPU_VISIBLE_BIT); @@ -1275,10 +1276,15 @@ static void demo_init_connection(struct demo *demo) #endif } -static void demo_init(struct demo *demo) +static void demo_init(struct demo *demo, const int argc, const char *argv[]) { memset(demo, 0, sizeof(*demo)); + for (int i = 0; i < argc; i++) { + if (strncmp(argv[i], "--use_staging", strlen("--use_staging")) == 0) + demo->use_staging_buffer = true; + } + demo_init_connection(demo); demo_init_xgl(demo); @@ -1341,11 +1347,11 @@ static void demo_cleanup(struct demo *demo) #endif } -int main(void) +int main(const int argc, const char *argv[]) { struct demo demo; - demo_init(&demo); + demo_init(&demo, argc, argv); demo_prepare(&demo); demo_create_window(&demo); -- cgit v1.2.3