int draw offsets.
This commit is contained in:
parent
92f1a7cb40
commit
d695f637a8
|
@ -207,8 +207,8 @@ struct SavedState {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void Blitter::Draw(GLuint src_texture, uint32_t src_x, uint32_t src_y,
|
void Blitter::Draw(GLuint src_texture, int32_t src_x, int32_t src_y,
|
||||||
uint32_t src_width, uint32_t src_height, GLenum filter) {
|
int32_t src_width, int32_t src_height, GLenum filter) {
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
glDisable(GL_STENCIL_TEST);
|
glDisable(GL_STENCIL_TEST);
|
||||||
glDisablei(GL_BLEND, 0);
|
glDisablei(GL_BLEND, 0);
|
||||||
|
@ -246,11 +246,10 @@ void Blitter::Draw(GLuint src_texture, uint32_t src_x, uint32_t src_y,
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Blitter::BlitTexture2D(GLuint src_texture, uint32_t src_x, uint32_t src_y,
|
void Blitter::BlitTexture2D(GLuint src_texture, int32_t src_x, int32_t src_y,
|
||||||
uint32_t src_width, uint32_t src_height,
|
int32_t src_width, int32_t src_height,
|
||||||
uint32_t dest_x, uint32_t dest_y,
|
int32_t dest_x, int32_t dest_y, int32_t dest_width,
|
||||||
uint32_t dest_width, uint32_t dest_height,
|
int32_t dest_height, GLenum filter) {
|
||||||
GLenum filter) {
|
|
||||||
SavedState state;
|
SavedState state;
|
||||||
state.Save();
|
state.Save();
|
||||||
|
|
||||||
|
@ -265,11 +264,11 @@ void Blitter::BlitTexture2D(GLuint src_texture, uint32_t src_x, uint32_t src_y,
|
||||||
state.Restore();
|
state.Restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Blitter::CopyColorTexture2D(GLuint src_texture, uint32_t src_x,
|
void Blitter::CopyColorTexture2D(GLuint src_texture, int32_t src_x,
|
||||||
uint32_t src_y, uint32_t src_width,
|
int32_t src_y, int32_t src_width,
|
||||||
uint32_t src_height, uint32_t dest_texture,
|
int32_t src_height, GLuint dest_texture,
|
||||||
uint32_t dest_x, uint32_t dest_y,
|
int32_t dest_x, int32_t dest_y,
|
||||||
uint32_t dest_width, uint32_t dest_height,
|
int32_t dest_width, int32_t dest_height,
|
||||||
GLenum filter) {
|
GLenum filter) {
|
||||||
SavedState state;
|
SavedState state;
|
||||||
state.Save();
|
state.Save();
|
||||||
|
@ -292,11 +291,11 @@ void Blitter::CopyColorTexture2D(GLuint src_texture, uint32_t src_x,
|
||||||
state.Restore();
|
state.Restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Blitter::CopyDepthTexture(GLuint src_texture, uint32_t src_x,
|
void Blitter::CopyDepthTexture(GLuint src_texture, int32_t src_x, int32_t src_y,
|
||||||
uint32_t src_y, uint32_t src_width,
|
int32_t src_width, int32_t src_height,
|
||||||
uint32_t src_height, uint32_t dest_texture,
|
GLuint dest_texture, int32_t dest_x,
|
||||||
uint32_t dest_x, uint32_t dest_y,
|
int32_t dest_y, int32_t dest_width,
|
||||||
uint32_t dest_width, uint32_t dest_height) {
|
int32_t dest_height) {
|
||||||
SavedState state;
|
SavedState state;
|
||||||
state.Save();
|
state.Save();
|
||||||
|
|
||||||
|
|
|
@ -27,24 +27,24 @@ class Blitter {
|
||||||
bool Initialize();
|
bool Initialize();
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
void BlitTexture2D(GLuint src_texture, uint32_t src_x, uint32_t src_y,
|
void BlitTexture2D(GLuint src_texture, int32_t src_x, int32_t src_y,
|
||||||
uint32_t src_width, uint32_t src_height, uint32_t dest_x,
|
int32_t src_width, int32_t src_height, int32_t dest_x,
|
||||||
uint32_t dest_y, uint32_t dest_width, uint32_t dest_height,
|
int32_t dest_y, int32_t dest_width, int32_t dest_height,
|
||||||
GLenum filter);
|
GLenum filter);
|
||||||
|
|
||||||
void CopyColorTexture2D(GLuint src_texture, uint32_t src_x, uint32_t src_y,
|
void CopyColorTexture2D(GLuint src_texture, int32_t src_x, int32_t src_y,
|
||||||
uint32_t src_width, uint32_t src_height,
|
int32_t src_width, int32_t src_height,
|
||||||
uint32_t dest_texture, uint32_t dest_x,
|
GLuint dest_texture, int32_t dest_x, int32_t dest_y,
|
||||||
uint32_t dest_y, uint32_t dest_width,
|
int32_t dest_width, int32_t dest_height,
|
||||||
uint32_t dest_height, GLenum filter);
|
GLenum filter);
|
||||||
void CopyDepthTexture(GLuint src_texture, uint32_t src_x, uint32_t src_y,
|
void CopyDepthTexture(GLuint src_texture, int32_t src_x, int32_t src_y,
|
||||||
uint32_t src_width, uint32_t src_height,
|
int32_t src_width, int32_t src_height,
|
||||||
uint32_t dest_texture, uint32_t dest_x, uint32_t dest_y,
|
GLuint dest_texture, int32_t dest_x, int32_t dest_y,
|
||||||
uint32_t dest_width, uint32_t dest_height);
|
int32_t dest_width, int32_t dest_height);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Draw(GLuint src_texture, uint32_t src_x, uint32_t src_y,
|
void Draw(GLuint src_texture, int32_t src_x, int32_t src_y, int32_t src_width,
|
||||||
uint32_t src_width, uint32_t src_height, GLenum filter);
|
int32_t src_height, GLenum filter);
|
||||||
|
|
||||||
GLuint vertex_program_;
|
GLuint vertex_program_;
|
||||||
GLuint color_fragment_program_;
|
GLuint color_fragment_program_;
|
||||||
|
|
|
@ -1865,9 +1865,6 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateViewportState() {
|
||||||
uint32_t window_offset = regs[XE_GPU_REG_PA_SC_WINDOW_OFFSET].u32;
|
uint32_t window_offset = regs[XE_GPU_REG_PA_SC_WINDOW_OFFSET].u32;
|
||||||
window_offset_x = window_offset & 0x7FFF;
|
window_offset_x = window_offset & 0x7FFF;
|
||||||
window_offset_y = (window_offset >> 16) & 0x7FFF;
|
window_offset_y = (window_offset >> 16) & 0x7FFF;
|
||||||
draw_batcher_.set_window_offset(window_offset_x, window_offset_y);
|
|
||||||
} else {
|
|
||||||
draw_batcher_.set_window_offset(0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://www.x.org/docs/AMD/old/evergreen_3D_registers_v2.pdf
|
// http://www.x.org/docs/AMD/old/evergreen_3D_registers_v2.pdf
|
||||||
|
|
|
@ -77,13 +77,9 @@ class DrawBatcher {
|
||||||
|
|
||||||
PrimitiveType prim_type() const { return batch_state_.prim_type; }
|
PrimitiveType prim_type() const { return batch_state_.prim_type; }
|
||||||
|
|
||||||
void set_window_offset(uint32_t x, uint32_t y) {
|
|
||||||
active_draw_.header->window_offset.x = float(x);
|
|
||||||
active_draw_.header->window_offset.y = float(y);
|
|
||||||
}
|
|
||||||
void set_window_scalar(float width_scalar, float height_scalar) {
|
void set_window_scalar(float width_scalar, float height_scalar) {
|
||||||
active_draw_.header->window_offset.z = width_scalar;
|
active_draw_.header->window_scale.x = width_scalar;
|
||||||
active_draw_.header->window_offset.w = height_scalar;
|
active_draw_.header->window_scale.y = height_scalar;
|
||||||
}
|
}
|
||||||
void set_vtx_fmt(float xy, float z, float w) {
|
void set_vtx_fmt(float xy, float z, float w) {
|
||||||
active_draw_.header->vtx_fmt.x = xy;
|
active_draw_.header->vtx_fmt.x = xy;
|
||||||
|
@ -175,7 +171,7 @@ class DrawBatcher {
|
||||||
|
|
||||||
// This must match GL4Shader's header.
|
// This must match GL4Shader's header.
|
||||||
struct CommonHeader {
|
struct CommonHeader {
|
||||||
float4 window_offset; // tx,ty,sx,sy
|
float4 window_scale; // sx,sy, ?, ?
|
||||||
float4 vtx_fmt; //
|
float4 vtx_fmt; //
|
||||||
float4 alpha_test; // alpha test enable, func, ref, ?
|
float4 alpha_test; // alpha test enable, func, ref, ?
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ std::string GL4Shader::GetHeader() {
|
||||||
"\n"
|
"\n"
|
||||||
// This must match DrawBatcher::CommonHeader.
|
// This must match DrawBatcher::CommonHeader.
|
||||||
"struct StateData {\n"
|
"struct StateData {\n"
|
||||||
" vec4 window_offset;\n"
|
" vec4 window_scale;\n"
|
||||||
" vec4 vtx_fmt;\n"
|
" vec4 vtx_fmt;\n"
|
||||||
" vec4 alpha_test;\n"
|
" vec4 alpha_test;\n"
|
||||||
// TODO(benvanik): variable length.
|
// TODO(benvanik): variable length.
|
||||||
|
@ -196,7 +196,7 @@ bool GL4Shader::PrepareVertexShader(
|
||||||
" // Already multiplied by 1/W0, so pull it out.\n"
|
" // Already multiplied by 1/W0, so pull it out.\n"
|
||||||
" pos.z /= pos.w;\n"
|
" pos.z /= pos.w;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" pos.xy *= state.window_offset.zw;\n"
|
" pos.xy *= state.window_scale.xy;\n"
|
||||||
" return pos;\n"
|
" return pos;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
std::string source =
|
std::string source =
|
||||||
|
|
|
@ -524,16 +524,16 @@ TextureCache::TextureEntry* TextureCache::LookupAddress(uint32_t guest_address,
|
||||||
}
|
}
|
||||||
|
|
||||||
GLuint TextureCache::CopyTexture(Blitter* blitter, uint32_t guest_address,
|
GLuint TextureCache::CopyTexture(Blitter* blitter, uint32_t guest_address,
|
||||||
uint32_t x, uint32_t y, uint32_t width,
|
int32_t x, int32_t y, int32_t width,
|
||||||
uint32_t height, TextureFormat format,
|
int32_t height, TextureFormat format,
|
||||||
bool swap_channels, GLuint src_texture) {
|
bool swap_channels, GLuint src_texture) {
|
||||||
return ConvertTexture(blitter, guest_address, x, y, width, height, format,
|
return ConvertTexture(blitter, guest_address, x, y, width, height, format,
|
||||||
swap_channels, src_texture);
|
swap_channels, src_texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLuint TextureCache::ConvertTexture(Blitter* blitter, uint32_t guest_address,
|
GLuint TextureCache::ConvertTexture(Blitter* blitter, uint32_t guest_address,
|
||||||
uint32_t x, uint32_t y, uint32_t width,
|
int32_t x, int32_t y, int32_t width,
|
||||||
uint32_t height, TextureFormat format,
|
int32_t height, TextureFormat format,
|
||||||
bool swap_channels, GLuint src_texture) {
|
bool swap_channels, GLuint src_texture) {
|
||||||
const auto& config = texture_configs[uint32_t(format)];
|
const auto& config = texture_configs[uint32_t(format)];
|
||||||
if (config.format == GL_INVALID_ENUM) {
|
if (config.format == GL_INVALID_ENUM) {
|
||||||
|
|
|
@ -59,12 +59,12 @@ class TextureCache {
|
||||||
TextureEntryView* Demand(const TextureInfo& texture_info,
|
TextureEntryView* Demand(const TextureInfo& texture_info,
|
||||||
const SamplerInfo& sampler_info);
|
const SamplerInfo& sampler_info);
|
||||||
|
|
||||||
GLuint CopyTexture(Blitter* blitter, uint32_t guest_address, uint32_t x,
|
GLuint CopyTexture(Blitter* blitter, uint32_t guest_address, int32_t x,
|
||||||
uint32_t y, uint32_t width, uint32_t height,
|
int32_t y, int32_t width, int32_t height,
|
||||||
TextureFormat format, bool swap_channels,
|
TextureFormat format, bool swap_channels,
|
||||||
GLuint src_texture);
|
GLuint src_texture);
|
||||||
GLuint ConvertTexture(Blitter* blitter, uint32_t guest_address, uint32_t x,
|
GLuint ConvertTexture(Blitter* blitter, uint32_t guest_address, int32_t x,
|
||||||
uint32_t y, uint32_t width, uint32_t height,
|
int32_t y, int32_t width, int32_t height,
|
||||||
TextureFormat format, bool swap_channels,
|
TextureFormat format, bool swap_channels,
|
||||||
GLuint src_texture);
|
GLuint src_texture);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue