Closed dneto0 closed 6 years ago
I had a go at implementing this. I took a slightly different approach. I’m not sure whether it makes sense to have a “save” command in the test script because it seems more like a script debugging utility so it is very different from the other commands. Instead I’ve just added the -b
option which saves a buffer to the given file after the test section completes (the same as for the -i
option). You can specify a particular buffer using the -B
option to tell it the buffer’s binding number.
For the API, instead of adding a save_buffer
callback, I’ve added a general inspect
callback which is invoked after a test is run. It has a pointer to a structure which is meant to be a place to store all sorts of information. Currently it contains pointers to the color buffer and a struct for each buffer that the script uses. This is also enough to move the image saving code into the application instead of having an option on vr_config
. Hopefully this will also make it easier to integrate with CTS if it wants to save the images in the XML file or something.
The API now looks like this:
struct vr_inspect_image {
/* Dimensions of the buffer */
int width, height;
/* The stride in pixels from one row of the image to the next */
size_t stride;
/* An opaque pointer describing the format of each pixel in
* the buffer
*/
const struct vr_format *format;
/* The buffer data */
const void *data;
};
struct vr_inspect_buffer {
/* The binding number of the buffer */
int binding;
/* Size in bytes of the buffer */
size_t size;
/* The buffer data */
const void *data;
};
struct vr_inspect_data {
/* The color buffer */
struct vr_inspect_image color_buffer;
/* An array of buffers used as UBOs or SSBOs */
size_t n_buffers;
const struct vr_inspect_buffer *buffers;
};
typedef void
(* vr_config_inspect_cb)(const struct vr_inspect_data *inspect_data,
void *user_data);
/* Sets a callback to invoke after the commands in the test section
* have run. It is not invoked if the test fails before the test
* section is reached. The application can use the inspect struct to
* query the buffers used by the test.
*/
void
vr_config_set_inspect_cb(struct vr_config *config,
vr_config_inspect_cb inspect_cb);
The implementation is on a branch here. If you have any comments on this approach I’d be happy to hear them.
I'd like to be able to use vkrunner in an edit/compile cycle when debugging a shader issue. What would be useful there is to be able to the resulting contents of a buffer after the pipeline is executed. It would be similar to -i command line option.
I think I would only need to look at the contents of one buffer. So I suggest the following:
Add a "save" verb of the form:
save ssbo
At the API level, add:
// Pointer-to-function for saving buffer. typdef void (vr_config_data_cb)(uint8_t data, size_t num_bytes, void* user_data);
// Set a callback for getting the contents of a buffer after a test has finished. // This is called for each buffer named by a "save" verb in the test script.
// When there is more than one, they are called exactly once, in order. By default // there is no callback set. Setting a null pointer will turn off the callback. vr_config_set_save_buffer_cb(struct vr_config *config, vr_config_data_cb save_cb);
Add a command-line option to the vkrunner to specify an output file for the binary data. Maybe:
-b BUFFER_FILE Write the contents of a "save" buffer to the given file.
For now I don't care that much about supporting multiple save buffers. But I would suggest that if multiple -b options are provided, that each would map to the "save" directives, in order