extend constructed type info with 'pointer depth', to distinguish between inline-depths; use in symbolizing & call stack expression formation

This commit is contained in:
Ryan Fleury
2025-02-11 16:16:44 -08:00
parent 312ddd5899
commit 98ec6ee3bb
13 changed files with 140 additions and 58 deletions
-1
View File
@@ -27,7 +27,6 @@ D_CmdTable: // | | | |
//- rjf: high-level composite target control operations
{RunToLine 0 1 Null null Nil Null 0 0 0 0 0 0 Play "run_to_line" "Run To Line" "Runs until a particular source line is hit." "" "$text_pt," }
{RunToAddress 1 1 Vaddr null Nil Null 0 0 0 0 1 1 PlayStepForward "run_to_address" "Run To Address" "Runs until a particular address is hit." "" "" }
{Run 1 1 Null null Nil Null 0 0 0 0 0 0 Play "run" "Run" "Runs all targets after starting them if they have not been started yet." "play" "" }
{Restart 1 1 Null null Nil Null 0 0 0 0 0 0 Redo "restart" "Restart" "Kills all attached processes, then launches all active targets." "restart,retry" "" }
{StepInto 1 1 Null null Nil Null 0 0 0 0 0 0 StepInto "step_into" "Step Into" "Steps once, possibly into function calls, for either source lines or instructions (whichever is selected)." "" "" }
+92 -25
View File
@@ -669,35 +669,101 @@ d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread)
//- rjf: symbol lookups
internal String8
d_symbol_name_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff, B32 decorated)
d_symbol_name_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff, U64 depth, B32 decorated)
{
String8 result = {0};
{
Temp scratch = scratch_begin(&arena, 1);
DI_Scope *scope = di_scope_open();
RDI_Parsed *rdi = di_rdi_from_key(scope, dbgi_key, 0);
//- rjf: try scopes
if(result.size == 0)
{
// rjf: voff -> scope
U64 scope_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_ScopeVMap, voff);
RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, scope_idx);
U64 proc_idx = scope->proc_idx;
RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, proc_idx);
E_TypeKey type = e_type_key_ext(E_TypeKind_Function, procedure->type_idx, e_parse_ctx_module_idx_from_rdi(rdi));
String8 name = {0};
name.str = rdi_string_from_idx(rdi, procedure->name_string_idx, &name.size);
if(decorated && procedure->type_idx != 0)
// rjf: scope -> # of max possible inline depth
U64 inline_site_count = 0;
for(U64 s_idx = scope_idx, s_idx_next = 0; s_idx != 0; s_idx = s_idx_next)
{
String8List list = {0};
e_type_lhs_string_from_key(scratch.arena, type, &list, 0, 0);
str8_list_push(scratch.arena, &list, name);
e_type_rhs_string_from_key(scratch.arena, type, &list, 0);
result = str8_list_join(arena, &list, 0);
RDI_Scope *s = rdi_element_from_name_idx(rdi, Scopes, s_idx);
s_idx_next = s->parent_scope_idx;
if(s->inline_site_idx != 0)
{
inline_site_count += 1;
}
else
{
break;
}
}
// rjf: depth in [1, max]? -> form name from inline site
if(0 < depth && depth <= inline_site_count)
{
RDI_InlineSite *inline_site = 0;
U64 s_inline_depth = inline_site_count;
for(U64 s_idx = scope_idx, s_idx_next = 0; s_idx != 0; s_idx = s_idx_next)
{
RDI_Scope *s = rdi_element_from_name_idx(rdi, Scopes, s_idx);
s_idx_next = s->parent_scope_idx;
if(s_inline_depth == depth)
{
inline_site = rdi_element_from_name_idx(rdi, InlineSites, s->inline_site_idx);
break;
}
s_inline_depth -= 1;
if(s_inline_depth == 0)
{
break;
}
}
if(inline_site != 0)
{
E_TypeKey type = e_type_key_ext(E_TypeKind_Function, inline_site->type_idx, e_parse_ctx_module_idx_from_rdi(rdi));
String8 name = {0};
name.str = rdi_string_from_idx(rdi, inline_site->name_string_idx, &name.size);
if(decorated && inline_site->type_idx != 0)
{
String8List list = {0};
e_type_lhs_string_from_key(scratch.arena, type, &list, 0, 0);
str8_list_push(scratch.arena, &list, name);
e_type_rhs_string_from_key(scratch.arena, type, &list, 0);
result = str8_list_join(arena, &list, 0);
}
else
{
result = push_str8_copy(arena, name);
}
}
}
// rjf: depth == 0 or depth >= max? -> form name from scope procedure
else
{
result = push_str8_copy(arena, name);
RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, scope_idx);
U64 proc_idx = scope->proc_idx;
RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, proc_idx);
E_TypeKey type = e_type_key_ext(E_TypeKind_Function, procedure->type_idx, e_parse_ctx_module_idx_from_rdi(rdi));
String8 name = {0};
name.str = rdi_string_from_idx(rdi, procedure->name_string_idx, &name.size);
if(decorated && procedure->type_idx != 0)
{
String8List list = {0};
e_type_lhs_string_from_key(scratch.arena, type, &list, 0, 0);
str8_list_push(scratch.arena, &list, name);
e_type_rhs_string_from_key(scratch.arena, type, &list, 0);
result = str8_list_join(arena, &list, 0);
}
else
{
result = push_str8_copy(arena, name);
}
}
}
//- rjf: try global variables
if(result.size == 0)
{
U64 global_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_GlobalVMap, voff);
@@ -706,6 +772,7 @@ d_symbol_name_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff, B32 d
U8 *name_ptr = rdi_string_from_idx(rdi, global_var->name_string_idx, &name_size);
result = push_str8_copy(arena, str8(name_ptr, name_size));
}
di_scope_close(scope);
scratch_end(scratch);
}
@@ -713,7 +780,7 @@ d_symbol_name_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff, B32 d
}
internal String8
d_symbol_name_from_process_vaddr(Arena *arena, CTRL_Entity *process, U64 vaddr, B32 decorated)
d_symbol_name_from_process_vaddr(Arena *arena, CTRL_Entity *process, U64 vaddr, U64 depth, B32 decorated)
{
ProfBeginFunction();
String8 result = {0};
@@ -721,7 +788,7 @@ d_symbol_name_from_process_vaddr(Arena *arena, CTRL_Entity *process, U64 vaddr,
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
U64 voff = ctrl_voff_from_vaddr(module, vaddr);
result = d_symbol_name_from_dbgi_key_voff(arena, &dbgi_key, voff, decorated);
result = d_symbol_name_from_dbgi_key_voff(arena, &dbgi_key, voff, depth, decorated);
}
ProfEnd();
return result;
@@ -2173,15 +2240,15 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
{
run_extra_bps.count = 1;
run_extra_bps.v = push_array(scratch.arena, D_Breakpoint, 1);
run_extra_bps.v[0].file_path = params->file_path;
run_extra_bps.v[0].pt = params->cursor;
d_cmd(D_CmdKind_Run);
}break;
case D_CmdKind_RunToAddress:
{
run_extra_bps.count = 1;
run_extra_bps.v = push_array(scratch.arena, D_Breakpoint, 1);
run_extra_bps.v[0].vaddr = params->vaddr;
if(params->file_path.size != 0)
{
run_extra_bps.v[0].file_path = params->file_path;
run_extra_bps.v[0].pt = params->cursor;
}
else if(params->vaddr != 0)
{
run_extra_bps.v[0].vaddr = params->vaddr;
}
d_cmd(D_CmdKind_Run);
}break;
case D_CmdKind_Run:
+2 -2
View File
@@ -433,8 +433,8 @@ internal CTRL_TrapList d_trap_net_from_thread__step_into_line(Arena *arena, CTRL
//~ rjf: Debug Info Lookups
//- rjf: voff|vaddr -> symbol lookups
internal String8 d_symbol_name_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff, B32 decorated);
internal String8 d_symbol_name_from_process_vaddr(Arena *arena, CTRL_Entity *process, U64 vaddr, B32 decorated);
internal String8 d_symbol_name_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff, U64 depth, B32 decorated);
internal String8 d_symbol_name_from_process_vaddr(Arena *arena, CTRL_Entity *process, U64 vaddr, U64 depth, B32 decorated);
//- rjf: symbol -> voff lookups
internal U64 d_voff_from_dbgi_key_symbol_name(DI_Key *dbgi_key, String8 symbol_name);
@@ -24,7 +24,6 @@ D_CmdKind_Halt,
D_CmdKind_SoftHaltRefresh,
D_CmdKind_SetThreadIP,
D_CmdKind_RunToLine,
D_CmdKind_RunToAddress,
D_CmdKind_Run,
D_CmdKind_Restart,
D_CmdKind_StepInto,
+5 -1
View File
@@ -323,6 +323,8 @@ e_hash_from_cons_type_params(E_ConsTypeParams *params)
params->direct_key.u32[2],
(U32)((params->count & 0x00000000ffffffffull)>> 0),
(U32)((params->count & 0xffffffff00000000ull)>> 32),
(U32)((params->depth & 0x00000000ffffffffull)>> 0),
(U32)((params->depth & 0xffffffff00000000ull)>> 32),
};
U64 hash = e_hash_from_string(5381, str8((U8 *)buffer, sizeof(buffer)));
hash = e_hash_from_string(hash, params->name);
@@ -336,7 +338,8 @@ e_cons_type_params_match(E_ConsTypeParams *l, E_ConsTypeParams *r)
l->flags == r->flags &&
str8_match(l->name, r->name, 0) &&
e_type_key_match(l->direct_key, r->direct_key) &&
l->count == r->count);
l->count == r->count &&
l->depth == r->depth);
if(result && l->members != 0 && r->members != 0)
{
for(U64 idx = 0; idx < l->count; idx += 1)
@@ -628,6 +631,7 @@ e_type_from_key(Arena *arena, E_TypeKey key)
type->name = push_str8_copy(arena, node->params.name);
type->direct_type_key = node->params.direct_key;
type->count = node->params.count;
type->depth = node->params.depth;
type->byte_size = node->byte_size;
switch(type->kind)
{
+2
View File
@@ -129,6 +129,7 @@ struct E_Type
String8 name;
U64 byte_size;
U64 count;
U64 depth;
U32 off;
E_TypeKey direct_type_key;
E_TypeKey owner_type_key;
@@ -176,6 +177,7 @@ struct E_ConsTypeParams
String8 name;
E_TypeKey direct_key;
U64 count;
U64 depth;
E_Member *members;
E_EnumVal *enum_vals;
};
+1 -2
View File
@@ -154,7 +154,7 @@ Rng1U64 rd_reg_slot_range_table[38] =
{OffsetOf(RD_Regs, os_event), OffsetOf(RD_Regs, os_event) + sizeof(OS_Event *)},
};
RD_CmdKindInfo rd_cmd_kind_info_table[213] =
RD_CmdKindInfo rd_cmd_kind_info_table[212] =
{
{0},
{ str8_lit_comp("launch_and_run"), str8_lit_comp("Starts debugging a new instance of a target, then runs."), str8_lit_comp("launch,start,run,target"), str8_lit_comp(""), str8_lit_comp("Launch and Run"), RD_IconKind_Play, (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*1), RD_RegSlot_Cfg, str8_lit_comp(""), CTRL_EntityKind_Null}},
@@ -172,7 +172,6 @@ RD_CmdKindInfo rd_cmd_kind_info_table[213] =
{ str8_lit_comp("soft_halt_refresh"), str8_lit_comp("Interrupts all attached processes to collect data, and then resumes them."), str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("Soft Halt Refresh"), RD_IconKind_Refresh, (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), CTRL_EntityKind_Null}},
{ str8_lit_comp("set_thread_ip"), str8_lit_comp("Sets the specified thread's instruction pointer at the specified address."), str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("Set Thread IP"), RD_IconKind_Null, (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*1)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*1), RD_RegSlot_Vaddr, str8_lit_comp(""), CTRL_EntityKind_Null}},
{ str8_lit_comp("run_to_line"), str8_lit_comp("Runs until a particular source line is hit."), str8_lit_comp(""), str8_lit_comp("$text_pt,"), str8_lit_comp("Run To Line"), RD_IconKind_Play, (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), CTRL_EntityKind_Null}},
{ str8_lit_comp("run_to_address"), str8_lit_comp("Runs until a particular address is hit."), str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("Run To Address"), RD_IconKind_PlayStepForward, (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*1)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*1), RD_RegSlot_Vaddr, str8_lit_comp(""), CTRL_EntityKind_Null}},
{ str8_lit_comp("run"), str8_lit_comp("Runs all targets after starting them if they have not been started yet."), str8_lit_comp("play"), str8_lit_comp(""), str8_lit_comp("Run"), RD_IconKind_Play, (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), CTRL_EntityKind_Null}},
{ str8_lit_comp("restart"), str8_lit_comp("Kills all attached processes, then launches all active targets."), str8_lit_comp("restart,retry"), str8_lit_comp(""), str8_lit_comp("Restart"), RD_IconKind_Redo, (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), CTRL_EntityKind_Null}},
{ str8_lit_comp("step_into"), str8_lit_comp("Steps once, possibly into function calls, for either source lines or instructions (whichever is selected)."), str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("Step Into"), RD_IconKind_StepInto, (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), CTRL_EntityKind_Null}},
-1
View File
@@ -76,7 +76,6 @@ RD_CmdKind_Halt,
RD_CmdKind_SoftHaltRefresh,
RD_CmdKind_SetThreadIP,
RD_CmdKind_RunToLine,
RD_CmdKind_RunToAddress,
RD_CmdKind_Run,
RD_CmdKind_Restart,
RD_CmdKind_StepInto,
+8 -9
View File
@@ -4775,7 +4775,7 @@ rd_window_frame(void)
}
else
{
rd_cmd(RD_CmdKind_RunToAddress, .vaddr = regs->vaddr);
rd_cmd(RD_CmdKind_RunToLine, .vaddr = regs->vaddr);
}
ui_ctx_menu_close();
}
@@ -7366,10 +7366,7 @@ rd_window_frame(void)
{
String8 view_expr = rd_expr_from_cfg(selected_tab);
String8 view_file_path = rd_file_path_from_eval_string(rd_frame_arena(), view_expr);
if(view_file_path.size != 0)
{
rd_regs()->file_path = view_file_path;
}
rd_regs()->file_path = view_file_path;
}
//- rjf: build view container
@@ -9129,7 +9126,7 @@ E_LOOKUP_ACCESS_FUNCTION_DEF(call_stack)
CTRL_Entity *process = ctrl_entity_from_handle(d_state->ctrl_entity_store, accel->process);
CTRL_CallStackFrame *f = &call_stack->frames[rhs_value.u64];
result.irtree_and_type.root = e_irtree_set_space(arena, rd_eval_space_from_ctrl_entity(process, RD_EvalSpaceKind_CtrlEntity), e_irtree_const_u(arena, regs_rip_from_arch_block(accel->arch, f->regs)));
result.irtree_and_type.type_key = e_type_key_cons_ptr(process->arch, e_type_key_basic(E_TypeKind_Void), 1, 0);
result.irtree_and_type.type_key = e_type_key_cons(.arch = process->arch, .kind = E_TypeKind_Ptr, .direct_key = e_type_key_basic(E_TypeKind_Function), .count = 1, .depth = f->inline_depth);
result.irtree_and_type.mode = E_Mode_Value;
}
scratch_end(scratch);
@@ -9605,8 +9602,10 @@ rd_append_value_strings_from_eval(Arena *arena, EV_StringFlags flags, U32 defaul
case E_TypeKind_RRef:
{
// rjf: unpack type info
E_TypeKind type_kind = e_type_kind_from_key(e_type_unwrap(eval.type_key));
E_TypeKey direct_type_key = e_type_unwrap(e_type_ptee_from_key(e_type_unwrap(eval.type_key)));
E_TypeKey type_key = e_type_unwrap(eval.type_key);
E_Type *type = e_type_from_key__cached(type_key);
E_TypeKind type_kind = type->kind;
E_TypeKey direct_type_key = e_type_unwrap(e_type_ptee_from_key(type_key));
E_TypeKind direct_type_kind = e_type_kind_from_key(direct_type_key);
// rjf: unpack info about pointer destination
@@ -9623,7 +9622,7 @@ rd_append_value_strings_from_eval(Arena *arena, EV_StringFlags flags, U32 defaul
CTRL_Entity *thread = ctrl_entity_from_handle(d_state->ctrl_entity_store, rd_regs()->thread);
process = ctrl_process_from_entity(thread);
}
String8 symbol_name = d_symbol_name_from_process_vaddr(arena, process, value_eval.value.u64, 1);
String8 symbol_name = d_symbol_name_from_process_vaddr(arena, process, value_eval.value.u64, type->depth, 1);
// rjf: special case: push strings for textual string content
B32 did_content = 0;
+8 -1
View File
@@ -1287,6 +1287,13 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla
result.string = rd_value_string_from_eval(arena, string_flags, 10, font, font_size, max_size_px, result.eval);
result.can_edit = (ev_type_key_is_editable(result.eval.type_key) && result.eval.mode == E_Mode_Offset);
//- rjf: determine if inlined
E_Type *type = e_type_from_key__cached(result.eval.type_key);
if(type->depth > 0)
{
result.is_inlined = 1;
}
scratch_end(scratch);
}break;
@@ -4900,7 +4907,7 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, f_rip);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
U64 rip_voff = ctrl_voff_from_vaddr(module, f_rip);
String8 symbol_name = d_symbol_name_from_dbgi_key_voff(scratch.arena, &dbgi_key, rip_voff, 1);
String8 symbol_name = d_symbol_name_from_dbgi_key_voff(scratch.arena, &dbgi_key, rip_voff, 0, 1);
Annotation *annotation = push_array(scratch.arena, Annotation, 1);
annotation->name_string = symbol_name.size != 0 ? symbol_name : str8_lit("[external code]");
annotation->kind_string = str8_lit("Call Stack Frame");
+1
View File
@@ -97,6 +97,7 @@ struct RD_WatchRowCellInfo
B32 is_button;
B32 can_edit;
B32 is_errored;
B32 is_inlined;
String8 error_tooltip;
String8 inheritance_tooltip;
RD_ViewUIRule *view_ui_rule;
+18 -12
View File
@@ -672,8 +672,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);
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,16 +708,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);
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);
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_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);
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);
}
}
ProfEnd();
}
+3 -3
View File
@@ -171,9 +171,9 @@ struct R_D3D11_State
//~ rjf: Globals
global R_D3D11_State *r_d3d11_state = 0;
global R_D3D11_Window r_d3d11_window_nil = {&r_d3d11_window_nil};
global R_D3D11_Tex2D r_d3d11_tex2d_nil = {&r_d3d11_tex2d_nil};
global R_D3D11_Buffer r_d3d11_buffer_nil = {&r_d3d11_buffer_nil};
global read_only R_D3D11_Window r_d3d11_window_nil = {&r_d3d11_window_nil};
global read_only R_D3D11_Tex2D r_d3d11_tex2d_nil = {&r_d3d11_tex2d_nil};
global read_only R_D3D11_Buffer r_d3d11_buffer_nil = {&r_d3d11_buffer_nil};
////////////////////////////////
//~ rjf: Helpers