mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-05 05:18:40 +00:00
opengl render backend
This commit is contained in:
@@ -279,8 +279,7 @@ str8_lit_comp(
|
||||
" corner_radii_px.w,\n"
|
||||
" corner_radii_px.z,\n"
|
||||
" };\n"
|
||||
" float2 cornercoords__pct = float2(\n"
|
||||
" (c2v.vertex_id >> 1) ? 1.f : 0.f,\n"
|
||||
" float2 cornercoords__pct = float2((c2v.vertex_id >> 1) ? 1.f : 0.f,\n"
|
||||
" (c2v.vertex_id & 1) ? 0.f : 1.f);\n"
|
||||
" \n"
|
||||
" float2 vertex_position__pct = vertex_positions__scrn[c2v.vertex_id] / viewport_size;\n"
|
||||
|
||||
@@ -669,11 +669,11 @@ r_tex2d_release(R_Handle handle)
|
||||
ProfBeginFunction();
|
||||
OS_MutexScopeW(r_d3d11_state->device_rw_mutex)
|
||||
{
|
||||
R_D3D11_Tex2D *texture = r_d3d11_tex2d_from_handle(handle);
|
||||
if(texture != &r_d3d11_tex2d_nil)
|
||||
{
|
||||
SLLStackPush(r_d3d11_state->first_to_free_tex2d, texture);
|
||||
}
|
||||
R_D3D11_Tex2D *texture = r_d3d11_tex2d_from_handle(handle);
|
||||
if(texture != &r_d3d11_tex2d_nil)
|
||||
{
|
||||
SLLStackPush(r_d3d11_state->first_to_free_tex2d, texture);
|
||||
}
|
||||
}
|
||||
ProfEnd();
|
||||
}
|
||||
@@ -705,19 +705,19 @@ r_fill_tex2d_region(R_Handle handle, Rng2S32 subrect, void *data)
|
||||
ProfBeginFunction();
|
||||
OS_MutexScopeW(r_d3d11_state->device_rw_mutex)
|
||||
{
|
||||
R_D3D11_Tex2D *texture = r_d3d11_tex2d_from_handle(handle);
|
||||
if(texture != &r_d3d11_tex2d_nil)
|
||||
{
|
||||
R_D3D11_Tex2D *texture = r_d3d11_tex2d_from_handle(handle);
|
||||
if(texture != &r_d3d11_tex2d_nil)
|
||||
{
|
||||
Assert(texture->kind == R_ResourceKind_Dynamic && "only dynamic texture can update region");
|
||||
U64 bytes_per_pixel = r_tex2d_format_bytes_per_pixel_table[texture->format];
|
||||
Vec2S32 dim = v2s32(subrect.x1 - subrect.x0, subrect.y1 - subrect.y0);
|
||||
Vec2S32 dim = v2s32(subrect.x1 - subrect.x0, subrect.y1 - subrect.y0);
|
||||
D3D11_BOX dst_box =
|
||||
{
|
||||
(UINT)subrect.x0, (UINT)subrect.y0, 0,
|
||||
(UINT)subrect.x1, (UINT)subrect.y1, 1,
|
||||
};
|
||||
r_d3d11_state->device_ctx->lpVtbl->UpdateSubresource(r_d3d11_state->device_ctx, (ID3D11Resource *)texture->texture, 0, &dst_box, data, dim.x*bytes_per_pixel, 0);
|
||||
}
|
||||
r_d3d11_state->device_ctx->lpVtbl->UpdateSubresource(r_d3d11_state->device_ctx, (ID3D11Resource *)texture->texture, 0, &dst_box, data, dim.x*bytes_per_pixel, 0);
|
||||
}
|
||||
}
|
||||
ProfEnd();
|
||||
}
|
||||
@@ -823,10 +823,10 @@ r_end_frame(void)
|
||||
tex = next)
|
||||
{
|
||||
next = tex->next;
|
||||
tex->view->lpVtbl->Release(tex->view);
|
||||
tex->texture->lpVtbl->Release(tex->texture);
|
||||
tex->view = 0;
|
||||
tex->texture = 0;
|
||||
tex->view->lpVtbl->Release(tex->view);
|
||||
tex->texture->lpVtbl->Release(tex->texture);
|
||||
tex->view = 0;
|
||||
tex->texture = 0;
|
||||
tex->generation += 1;
|
||||
SLLStackPush(r_d3d11_state->first_free_tex2d, tex);
|
||||
}
|
||||
@@ -1119,29 +1119,14 @@ r_window_submit(OS_Handle window, R_Handle window_equip, R_PassList *passes)
|
||||
R_D3D11_Tex2D *texture = r_d3d11_tex2d_from_handle(texture_handle);
|
||||
|
||||
// rjf: get texture sample map matrix, based on format
|
||||
Vec4F32 texture_sample_channel_map[] =
|
||||
{
|
||||
{1, 0, 0, 0},
|
||||
{0, 1, 0, 0},
|
||||
{0, 0, 1, 0},
|
||||
{0, 0, 0, 1},
|
||||
};
|
||||
switch(texture->format)
|
||||
{
|
||||
default: break;
|
||||
case R_Tex2DFormat_R8:
|
||||
{
|
||||
MemoryZeroArray(texture_sample_channel_map);
|
||||
texture_sample_channel_map[0] = v4f32(1, 1, 1, 1);
|
||||
}break;
|
||||
}
|
||||
Mat4x4F32 texture_sample_channel_map = r_sample_channel_map_from_tex2dformat(texture->format);
|
||||
|
||||
// rjf: upload uniforms
|
||||
R_D3D11_Uniforms_Rect uniforms = {0};
|
||||
{
|
||||
uniforms.viewport_size = v2f32(resolution.x, resolution.y);
|
||||
uniforms.opacity = 1-group_params->transparency;
|
||||
MemoryCopyArray(uniforms.texture_sample_channel_map, texture_sample_channel_map);
|
||||
uniforms.texture_sample_channel_map = texture_sample_channel_map;
|
||||
uniforms.texture_t2d_size = v2f32(texture->size.x, texture->size.y);
|
||||
uniforms.xform[0] = v4f32(group_params->xform.v[0][0], group_params->xform.v[1][0], group_params->xform.v[2][0], 0);
|
||||
uniforms.xform[1] = v4f32(group_params->xform.v[0][1], group_params->xform.v[1][1], group_params->xform.v[2][1], 0);
|
||||
|
||||
@@ -29,7 +29,7 @@ struct R_D3D11_Uniforms_Rect
|
||||
Vec2F32 viewport_size;
|
||||
F32 opacity;
|
||||
F32 _padding0_;
|
||||
Vec4F32 texture_sample_channel_map[4];
|
||||
Mat4x4F32 texture_sample_channel_map;
|
||||
Vec2F32 texture_t2d_size;
|
||||
Vec2F32 translate;
|
||||
Vec4F32 xform[3];
|
||||
|
||||
@@ -277,8 +277,7 @@ vs_main(CPU2Vertex c2v)
|
||||
corner_radii_px.w,
|
||||
corner_radii_px.z,
|
||||
};
|
||||
float2 cornercoords__pct = float2(
|
||||
(c2v.vertex_id >> 1) ? 1.f : 0.f,
|
||||
float2 cornercoords__pct = float2((c2v.vertex_id >> 1) ? 1.f : 0.f,
|
||||
(c2v.vertex_id & 1) ? 0.f : 1.f);
|
||||
|
||||
float2 vertex_position__pct = vertex_positions__scrn[c2v.vertex_id] / viewport_size;
|
||||
|
||||
Reference in New Issue
Block a user