Avoid more pointer grabbing for video driver ptr

This commit is contained in:
twinaphex 2018-02-16 20:42:37 +01:00
parent 35f1c9ba33
commit 070c09faec
10 changed files with 50 additions and 28 deletions

View File

@ -743,7 +743,8 @@ void d3d12_update_texture(
texture->dirty = true;
}
void d3d12_upload_texture(D3D12GraphicsCommandList cmd, d3d12_texture_t* texture)
void d3d12_upload_texture(D3D12GraphicsCommandList cmd,
d3d12_texture_t* texture, void *userdata)
{
D3D12_TEXTURE_COPY_LOCATION src = { 0 };
D3D12_TEXTURE_COPY_LOCATION dst = { 0 };
@ -769,7 +770,7 @@ void d3d12_upload_texture(D3D12GraphicsCommandList cmd, d3d12_texture_t* texture
if (texture->desc.MipLevels > 1)
{
unsigned i;
d3d12_video_t* d3d12 = (d3d12_video_t*)video_driver_get_ptr(false);
d3d12_video_t* d3d12 = (d3d12_video_t*)userdata;
D3D12SetComputeRootSignature(cmd, d3d12->desc.cs_rootSignature);
D3D12SetPipelineState(cmd, d3d12->mipmapgen_pipe);

View File

@ -1517,7 +1517,8 @@ void d3d12_update_texture(
const void* data,
d3d12_texture_t* texture);
void d3d12_upload_texture(D3D12GraphicsCommandList cmd, d3d12_texture_t* texture);
void d3d12_upload_texture(D3D12GraphicsCommandList cmd,
d3d12_texture_t* texture, void *userdata);
void d3d12_create_fullscreen_quad_vbo(
D3D12Device device, D3D12_VERTEX_BUFFER_VIEW* view, D3D12Resource* vbo);

View File

@ -1181,7 +1181,8 @@ static bool d3d12_gfx_frame(
{
if (d3d12->shader_preset->luts && d3d12->luts[0].dirty)
for (i = 0; i < d3d12->shader_preset->luts; i++)
d3d12_upload_texture(d3d12->queue.cmd, &d3d12->luts[i]);
d3d12_upload_texture(d3d12->queue.cmd, &d3d12->luts[i],
video_info->userdata);
if (d3d12->frame.texture[0].desc.Width != width ||
d3d12->frame.texture[0].desc.Height != height)
@ -1231,7 +1232,8 @@ static bool d3d12_gfx_frame(
d3d12_update_texture(width, height, pitch, d3d12->format, frame, &d3d12->frame.texture[0]);
d3d12_upload_texture(d3d12->queue.cmd, &d3d12->frame.texture[0]);
d3d12_upload_texture(d3d12->queue.cmd, &d3d12->frame.texture[0],
video_info->userdata);
}
D3D12IASetVertexBuffers(d3d12->queue.cmd, 0, 1, &d3d12->frame.vbo_view);
@ -1422,7 +1424,8 @@ static bool d3d12_gfx_frame(
if (d3d12->menu.enabled && d3d12->menu.texture.handle)
{
if (d3d12->menu.texture.dirty)
d3d12_upload_texture(d3d12->queue.cmd, &d3d12->menu.texture);
d3d12_upload_texture(d3d12->queue.cmd, &d3d12->menu.texture,
video_info->userdata);
D3D12SetGraphicsRootConstantBufferView(
d3d12->queue.cmd, ROOT_ID_UBO, d3d12->ubo_view.BufferLocation);
@ -1477,7 +1480,9 @@ static bool d3d12_gfx_frame(
for (i = 0; i < d3d12->overlays.count; i++)
{
if (d3d12->overlays.textures[i].dirty)
d3d12_upload_texture(d3d12->queue.cmd, &d3d12->overlays.textures[i]);
d3d12_upload_texture(d3d12->queue.cmd,
&d3d12->overlays.textures[i],
video_info->userdata);
D3D12SetGraphicsRootDescriptorTable(
d3d12->queue.cmd, ROOT_ID_TEXTURE_T, d3d12->overlays.textures[i].gpu_descriptor[0]);

View File

@ -60,7 +60,8 @@ static bool widescreen_mode = false;
void *dinput;
static bool gfx_ctx_d3d_set_resize(void *data, unsigned new_width, unsigned new_height)
static bool gfx_ctx_d3d_set_resize(void *data,
unsigned new_width, unsigned new_height)
{
d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(false);
@ -68,7 +69,8 @@ static bool gfx_ctx_d3d_set_resize(void *data, unsigned new_width, unsigned new_
return false;
/* No changes? */
if (new_width == d3d->video_info.width && new_height == d3d->video_info.height)
if ( (new_width == d3d->video_info.width)
&& (new_height == d3d->video_info.height))
return false;
RARCH_LOG("[D3D]: Resize %ux%u.\n", new_width, new_height);

View File

@ -161,7 +161,7 @@ static void ctr_font_render_line(
unsigned i;
ctr_vertex_t* v = NULL;
ctr_video_t* ctr = (ctr_video_t*)video_driver_get_ptr(false);
ctr_video_t* ctr = (ctr_video_t*)video_info->userdata;
unsigned width = video_info->width;
unsigned height = video_info->height;
int x = roundf(pos_x * width);
@ -169,6 +169,9 @@ static void ctr_font_render_line(
int delta_x = 0;
int delta_y = 0;
if (!ctr)
return;
switch (text_align)
{
case TEXT_ALIGN_RIGHT:

View File

@ -130,13 +130,15 @@ static void d3d11_font_render_line(
unsigned i, count;
D3D11_MAPPED_SUBRESOURCE mapped_vbo;
d3d11_sprite_t* v;
d3d11_video_t* d3d11 = (d3d11_video_t*)video_driver_get_ptr(false);
d3d11_video_t* d3d11 = (d3d11_video_t*)video_info->userdata;
unsigned width = video_info->width;
unsigned height = video_info->height;
int x = roundf(pos_x * width);
int y = roundf((1.0 - pos_y) * height);
if (!d3d11->sprites.enabled || msg_len > (unsigned)d3d11->sprites.capacity)
if ( !d3d11 ||
!d3d11->sprites.enabled ||
msg_len > (unsigned)d3d11->sprites.capacity)
return;
if (d3d11->sprites.offset + msg_len > (unsigned)d3d11->sprites.capacity)

View File

@ -131,14 +131,14 @@ static void d3d12_font_render_line(
void* mapped_vbo;
d3d12_sprite_t* v;
d3d12_sprite_t* vbo_start;
d3d12_video_t* d3d12 = (d3d12_video_t*)video_driver_get_ptr(false);
d3d12_video_t* d3d12 = (d3d12_video_t*)video_info->userdata;
unsigned width = video_info->width;
unsigned height = video_info->height;
int x = roundf(pos_x * width);
int y = roundf((1.0 - pos_y) * height);
D3D12_RANGE range = { 0, 0 };
if (!d3d12->sprites.enabled || msg_len > (unsigned)d3d12->sprites.capacity)
if (!d3d12 || !d3d12->sprites.enabled || msg_len > (unsigned)d3d12->sprites.capacity)
return;
if (d3d12->sprites.offset + msg_len > (unsigned)d3d12->sprites.capacity)
@ -219,7 +219,8 @@ static void d3d12_font_render_line(
}
if(font->texture.dirty)
d3d12_upload_texture(d3d12->queue.cmd, &font->texture);
d3d12_upload_texture(d3d12->queue.cmd, &font->texture,
video_info->userdata);
D3D12SetPipelineState(d3d12->queue.cmd, d3d12->sprites.pipe_font);
d3d12_set_texture_and_sampler(d3d12->queue.cmd, &font->texture);

View File

@ -150,13 +150,14 @@ static void wiiu_font_render_line(
float pos_y, unsigned text_align)
{
unsigned i;
wiiu_video_t* wiiu = (wiiu_video_t*)video_driver_get_ptr(false);
wiiu_video_t* wiiu = (wiiu_video_t*)video_info->userdata;
unsigned width = video_info->width;
unsigned height = video_info->height;
int x = roundf(pos_x * width);
int y = roundf((1.0 - pos_y) * height);
if(wiiu->vertex_cache.current + (msg_len * 4) > wiiu->vertex_cache.size)
if( !wiiu ||
wiiu->vertex_cache.current + (msg_len * 4) > wiiu->vertex_cache.size)
return;
switch (text_align)

View File

@ -614,7 +614,8 @@ void input_overlay_loaded(void *task_data, void *user_data, const char *err)
ol->overlays = data->overlays;
ol->size = data->size;
ol->active = data->active;
ol->iface = iface; ol->iface_data = video_driver_get_ptr(true);
ol->iface = iface;
ol->iface_data = video_driver_get_ptr(true);
input_overlay_load_active(ol, data->overlay_opacity);
input_overlay_enable(ol, data->overlay_enable);

View File

@ -127,13 +127,13 @@ static void menu_display_d3d12_draw(void* data, video_frame_info_t *video_info)
sprite->params.rotation = draw->rotation;
sprite->colors[3] = DXGI_COLOR_RGBA(
0xFF * draw->coords->color[0], 0xFF * draw->coords->color[1],
0xFF * draw->coords->color[2], 0xFF * draw->coords->color[3]);
0xFF * draw->coords->color[0], 0xFF * draw->coords->color[1],
0xFF * draw->coords->color[2], 0xFF * draw->coords->color[3]);
sprite->colors[2] = DXGI_COLOR_RGBA(
0xFF * draw->coords->color[4], 0xFF * draw->coords->color[5],
0xFF * draw->coords->color[6], 0xFF * draw->coords->color[7]);
0xFF * draw->coords->color[4], 0xFF * draw->coords->color[5],
0xFF * draw->coords->color[6], 0xFF * draw->coords->color[7]);
sprite->colors[1] = DXGI_COLOR_RGBA(
0xFF * draw->coords->color[8], 0xFF * draw->coords->color[9],
0xFF * draw->coords->color[8], 0xFF * draw->coords->color[9],
0xFF * draw->coords->color[10], 0xFF * draw->coords->color[11]);
sprite->colors[0] = DXGI_COLOR_RGBA(
0xFF * draw->coords->color[12], 0xFF * draw->coords->color[13],
@ -160,8 +160,10 @@ static void menu_display_d3d12_draw(void* data, video_frame_info_t *video_info)
sprite++;
}
D3D12SetPipelineState(d3d12->queue.cmd, d3d12->pipes[VIDEO_SHADER_STOCK_BLEND]);
D3D12IASetPrimitiveTopology(d3d12->queue.cmd, D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
D3D12SetPipelineState(d3d12->queue.cmd,
d3d12->pipes[VIDEO_SHADER_STOCK_BLEND]);
D3D12IASetPrimitiveTopology(d3d12->queue.cmd,
D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
}
range.Begin = d3d12->sprites.offset * sizeof(*sprite);
@ -173,12 +175,15 @@ static void menu_display_d3d12_draw(void* data, video_frame_info_t *video_info)
d3d12_texture_t* texture = (d3d12_texture_t*)draw->texture;
if (texture->dirty)
{
d3d12_upload_texture(d3d12->queue.cmd, texture);
d3d12_upload_texture(d3d12->queue.cmd,
texture, video_info->userdata);
if (vertex_count > 1)
D3D12SetPipelineState(d3d12->queue.cmd, d3d12->pipes[VIDEO_SHADER_STOCK_BLEND]);
D3D12SetPipelineState(d3d12->queue.cmd,
d3d12->pipes[VIDEO_SHADER_STOCK_BLEND]);
else
D3D12SetPipelineState(d3d12->queue.cmd, d3d12->sprites.pipe);
D3D12SetPipelineState(d3d12->queue.cmd,
d3d12->sprites.pipe);
}
d3d12_set_texture_and_sampler(d3d12->queue.cmd, texture);
}