formatting
This commit is contained in:
parent
e7bdb1c24f
commit
c6e70e201e
@ -1475,15 +1475,10 @@ void gpu_run_pass(struct gpu_pass_state gpu_pass_state, struct gpu_pass_params p
|
||||
__profscope_dx11(G.profiling_ctx, Run pass, RGB_F(0.5, 0.2, 0.2));
|
||||
struct sprite_scope *sprite_scope = sprite_scope_begin();
|
||||
struct dx11_pass_state *pass_state = (struct dx11_pass_state *)gpu_pass_state.handle;
|
||||
|
||||
|
||||
|
||||
(UNUSED)pass_state;
|
||||
|
||||
|
||||
struct dx11_texture *draw_target = (struct dx11_texture *)params.draw_target.handle;
|
||||
struct rect viewport = params.draw_target_viewport;
|
||||
struct mat4x4 vp_matrix = calculate_vp(XFORM_IDENT, viewport.width, viewport.height);
|
||||
|
||||
/* Set render targets */
|
||||
ID3D11DeviceContext_OMSetRenderTargets(G.devcon, 1, &draw_target->rtv, NULL);
|
||||
@ -1497,6 +1492,7 @@ void gpu_run_pass(struct gpu_pass_state gpu_pass_state, struct gpu_pass_params p
|
||||
d3d11_viewport.TopLeftY = viewport.y;
|
||||
ID3D11DeviceContext_RSSetViewports(G.devcon, 1, &d3d11_viewport);
|
||||
|
||||
struct mat4x4 vp_matrix = calculate_vp(XFORM_IDENT, viewport.width, viewport.height);
|
||||
for (u64 cmd_stores_array_index = 0; cmd_stores_array_index < params.cmds_array.count; ++cmd_stores_array_index) {
|
||||
struct dx11_cmd_store *store = (struct dx11_cmd_store *)params.cmds_array.cmds[cmd_stores_array_index]->handle;
|
||||
for (struct dx11_cmd *cmd = store->gpu_first_cmd; cmd; cmd = cmd->next) {
|
||||
@ -1505,7 +1501,7 @@ void gpu_run_pass(struct gpu_pass_state gpu_pass_state, struct gpu_pass_params p
|
||||
switch (cmd_kind) {
|
||||
default:
|
||||
{
|
||||
/* Unknown shader */
|
||||
/* Unknown cmd kind */
|
||||
ASSERT(false);
|
||||
} break;
|
||||
|
||||
@ -1722,7 +1718,7 @@ void gpu_run_pass(struct gpu_pass_state gpu_pass_state, struct gpu_pass_params p
|
||||
|
||||
INTERNAL struct dx11_format dx11_format_from_gpu_format(enum gpu_texture_format format)
|
||||
{
|
||||
LOCAL_PERSIST const struct dx11_format sizes[NUM_GPU_TEXTURE_FORMATS] = {
|
||||
LOCAL_PERSIST struct dx11_format dx11_formats[NUM_GPU_TEXTURE_FORMATS] = {
|
||||
[GPU_TEXTURE_FORMAT_R8G8B8A8_UNORM] = {
|
||||
.format = DXGI_FORMAT_R8G8B8A8_UNORM,
|
||||
.pixel_size = 4
|
||||
@ -1732,14 +1728,15 @@ INTERNAL struct dx11_format dx11_format_from_gpu_format(enum gpu_texture_format
|
||||
.pixel_size = 4
|
||||
}
|
||||
};
|
||||
|
||||
struct dx11_format res = ZI;
|
||||
if ((u32)format < ARRAY_COUNT(sizes)) {
|
||||
res = sizes[format];
|
||||
if ((u32)format < ARRAY_COUNT(dx11_formats)) {
|
||||
res = dx11_formats[format];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
INTERNAL struct dx11_texture *dx11_texture_alloc(enum gpu_texture_format format, u32 flags, struct v2i32 size, void *initial_data)
|
||||
INTERNAL struct dx11_texture *dx11_texture_alloc(struct dx11_format format, u32 flags, struct v2i32 size, void *initial_data)
|
||||
{
|
||||
struct dx11_texture *t = NULL;
|
||||
{
|
||||
@ -1754,18 +1751,6 @@ INTERNAL struct dx11_texture *dx11_texture_alloc(enum gpu_texture_format format,
|
||||
}
|
||||
MEMZERO_STRUCT(t);
|
||||
|
||||
struct dx11_format dx11_format = dx11_format_from_gpu_format(format);
|
||||
if (dx11_format.format == DXGI_FORMAT_UNKNOWN) {
|
||||
/* Unknown format */
|
||||
ASSERT(false);
|
||||
sys_panic(LIT("Unknown dx11 texture format during texture allocation"));
|
||||
}
|
||||
|
||||
u32 bind_flags = D3D11_BIND_SHADER_RESOURCE;
|
||||
if (flags & GPU_TEXTURE_FLAG_TARGETABLE) {
|
||||
bind_flags |= D3D11_BIND_RENDER_TARGET;
|
||||
}
|
||||
|
||||
D3D11_TEXTURE2D_DESC desc = ZI;
|
||||
desc.Width = max_i32(size.x, 1);
|
||||
desc.Height = max_i32(size.y, 1);
|
||||
@ -1774,13 +1759,13 @@ INTERNAL struct dx11_texture *dx11_texture_alloc(enum gpu_texture_format format,
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.BindFlags = bind_flags;
|
||||
desc.Format = dx11_format.format;
|
||||
desc.BindFlags = flags;
|
||||
desc.Format = format.format;
|
||||
|
||||
/* Create texture */
|
||||
ID3D11Texture2D *texture = NULL;
|
||||
if (initial_data) {
|
||||
D3D11_SUBRESOURCE_DATA subresource_data = { .pSysMem = initial_data, .SysMemPitch = size.x * dx11_format.pixel_size, .SysMemSlicePitch = 0 };
|
||||
D3D11_SUBRESOURCE_DATA subresource_data = { .pSysMem = initial_data, .SysMemPitch = size.x * format.pixel_size, .SysMemSlicePitch = 0 };
|
||||
ID3D11Device_CreateTexture2D(G.dev, &desc, &subresource_data, &texture);
|
||||
} else {
|
||||
ID3D11Device_CreateTexture2D(G.dev, &desc, NULL, &texture);
|
||||
@ -1789,7 +1774,7 @@ INTERNAL struct dx11_texture *dx11_texture_alloc(enum gpu_texture_format format,
|
||||
t->texture = texture;
|
||||
|
||||
/* Create SRV */
|
||||
if (t->texture && (bind_flags & D3D11_BIND_SHADER_RESOURCE)) {
|
||||
if (t->texture && (flags & D3D11_BIND_SHADER_RESOURCE)) {
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc = ZI;
|
||||
srv_desc.Format = desc.Format;
|
||||
srv_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||
@ -1798,7 +1783,7 @@ INTERNAL struct dx11_texture *dx11_texture_alloc(enum gpu_texture_format format,
|
||||
}
|
||||
|
||||
/* Create RTV */
|
||||
if (t->texture && (bind_flags & D3D11_BIND_RENDER_TARGET)) {
|
||||
if (t->texture && (flags & D3D11_BIND_RENDER_TARGET)) {
|
||||
ID3D11Device_CreateRenderTargetView(G.dev, (ID3D11Resource *)t->texture, NULL, &t->rtv);
|
||||
}
|
||||
|
||||
@ -1830,7 +1815,22 @@ struct gpu_texture gpu_texture_alloc(enum gpu_texture_format format, u32 flags,
|
||||
{
|
||||
__prof;
|
||||
struct gpu_texture res = ZI;
|
||||
struct dx11_texture *t = dx11_texture_alloc(format, flags, size, initial_data);
|
||||
|
||||
/* Convert format to dx11 format */
|
||||
struct dx11_format dx11_format = dx11_format_from_gpu_format(format);
|
||||
if (dx11_format.format == DXGI_FORMAT_UNKNOWN) {
|
||||
/* Unknown format */
|
||||
ASSERT(false);
|
||||
sys_panic(LIT("Unknown dx11 texture format during texture allocation"));
|
||||
}
|
||||
|
||||
/* Convert flags to dx11 flags */
|
||||
u32 dx11_flags = D3D11_BIND_SHADER_RESOURCE;
|
||||
if (flags & GPU_TEXTURE_FLAG_TARGETABLE) {
|
||||
dx11_flags |= D3D11_BIND_RENDER_TARGET;
|
||||
}
|
||||
|
||||
struct dx11_texture *t = dx11_texture_alloc(dx11_format, dx11_flags, size, initial_data);
|
||||
res.handle = (u64)t;
|
||||
return res;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user