Skip to content

Commit

Permalink
Merge pull request #13928 from hrydgard/more-gpu-driver-tests
Browse files Browse the repository at this point in the history
Adds two new tests to GPU driver test screen: Adreno shader logic test and flat shading
  • Loading branch information
hrydgard committed Jan 17, 2021
2 parents abbc8a0 + c8bbf40 commit a88f6b4
Show file tree
Hide file tree
Showing 8 changed files with 356 additions and 11 deletions.
2 changes: 2 additions & 0 deletions Common/GPU/OpenGL/GLFeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,8 @@ std::string ApplyGLSLPrelude(const std::string &source, uint32_t stage) {
if (!gl_extensions.IsGLES && gl_extensions.IsCoreContext) {
// We need to add a corresponding #version. Apple drivers fail without an exact match.
version = StringFromFormat("#version %d\n", gl_extensions.GLSLVersion());
} else if (gl_extensions.IsGLES && gl_extensions.GLES3) {
version = StringFromFormat("#version %d es\n", gl_extensions.GLSLVersion());
}
if (stage == GL_FRAGMENT_SHADER) {
temp = version + glsl_fragment_prelude + source;
Expand Down
12 changes: 12 additions & 0 deletions Common/Render/DrawBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,18 @@ void DrawBuffer::DrawImageStretch(ImageID atlas_image, float x1, float y1, float
V(x1, y2, color, image->u1, image->v2);
}

void DrawBuffer::DrawImageStretchVGradient(ImageID atlas_image, float x1, float y1, float x2, float y2, Color color1, Color color2) {
const AtlasImage *image = atlas->getImage(atlas_image);
if (!image)
return;
V(x1, y1, color1, image->u1, image->v1);
V(x2, y1, color1, image->u2, image->v1);
V(x2, y2, color2, image->u2, image->v2);
V(x1, y1, color1, image->u1, image->v1);
V(x2, y2, color2, image->u2, image->v2);
V(x1, y2, color2, image->u1, image->v2);
}

inline void rot(float *v, float angle, float xc, float yc) {
const float x = v[0] - xc;
const float y = v[1] - yc;
Expand Down
1 change: 1 addition & 0 deletions Common/Render/DrawBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class DrawBuffer {
bool MeasureImage(ImageID atlas_image, float *w, float *h);
void DrawImage(ImageID atlas_image, float x, float y, float scale, Color color = COLOR(0xFFFFFF), int align = ALIGN_TOPLEFT);
void DrawImageStretch(ImageID atlas_image, float x1, float y1, float x2, float y2, Color color = COLOR(0xFFFFFF));
void DrawImageStretchVGradient(ImageID atlas_image, float x1, float y1, float x2, float y2, Color color1, Color color2);
void DrawImageStretch(ImageID atlas_image, const Bounds &bounds, Color color = COLOR(0xFFFFFF)) {
DrawImageStretch(atlas_image, bounds.x, bounds.y, bounds.x2(), bounds.y2(), color);
}
Expand Down
5 changes: 5 additions & 0 deletions Common/UI/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void UIContext::BeginNoTex() {
}

void UIContext::BeginPipeline(Draw::Pipeline *pipeline, Draw::SamplerState *samplerState) {
_assert_(pipeline != nullptr);
draw_->BindSamplerStates(0, 1, &samplerState);
RebindTexture();
UIBegin(pipeline);
Expand Down Expand Up @@ -236,6 +237,10 @@ void UIContext::FillRect(const UI::Drawable &drawable, const Bounds &bounds) {
}
}

void UIContext::DrawImageVGradient(ImageID image, uint32_t color1, uint32_t color2, const Bounds &bounds) {
uidrawbuffer_->DrawImageStretchVGradient(image, bounds.x, bounds.y, bounds.x2(), bounds.y2(), color1, color2);
}

void UIContext::PushTransform(const UITransform &transform) {
Flush();

Expand Down
1 change: 1 addition & 0 deletions Common/UI/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class UIContext {
void DrawTextShadow(const char *str, float x, float y, uint32_t color, int align = 0);
void DrawTextRect(const char *str, const Bounds &bounds, uint32_t color, int align = 0);
void FillRect(const UI::Drawable &drawable, const Bounds &bounds);
void DrawImageVGradient(ImageID image, uint32_t color1, uint32_t color2, const Bounds &bounds);

// in dps, like dp_xres and dp_yres
void SetBounds(const Bounds &b) { bounds_ = b; }
Expand Down
2 changes: 1 addition & 1 deletion GPU/Common/FragmentShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu

if (!strcmp(compat.fragColor0, "fragColor0")) {
const char *qualifierColor0 = "out";
if (compat.lastFragData && !strcmp(compat.lastFragData, compat.fragColor0)) {
if (readFramebuffer && compat.lastFragData && !strcmp(compat.lastFragData, compat.fragColor0)) {
qualifierColor0 = "inout";
}
// Output the output color definitions.
Expand Down
Loading

0 comments on commit a88f6b4

Please sign in to comment.